For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
[obnox/wireshark/wip.git] / epan / dissectors / packet-infiniband.c
1 /* packet-infiniband.c
2  * Routines for Infiniband/ERF Dissection
3  * Copyright 2008 Endace Technology Limited
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * Modified 2010 by Mellanox Technologies Ltd.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <string.h>
33
34 #include <glib.h>
35 #include <epan/packet.h>
36 #include <epan/emem.h>
37 #include <epan/conversation.h>
38 #include <epan/prefs.h>
39 #include <epan/etypes.h>
40 #include <epan/dissectors/packet-frame.h>
41 #include "packet-infiniband.h"
42
43 #define PROTO_TAG_INFINIBAND    "Infiniband"
44
45 /* Wireshark ID */
46 static int proto_infiniband = -1;
47 static int proto_infiniband_link = -1;
48
49 /* Variables to hold expansion values between packets */
50 /* static gint ett_infiniband = -1;                */
51 static gint ett_all_headers = -1;
52 static gint ett_lrh = -1;
53 static gint ett_grh = -1;
54 static gint ett_bth = -1;
55 static gint ett_rwh = -1;
56 static gint ett_rdeth = -1;
57 static gint ett_deth = -1;
58 static gint ett_reth = -1;
59 static gint ett_atomiceth = -1;
60 static gint ett_aeth = -1;
61 static gint ett_atomicacketh = -1;
62 static gint ett_immdt = -1;
63 static gint ett_ieth = -1;
64 static gint ett_payload = -1;
65 static gint ett_vendor = -1;
66 static gint ett_subn_lid_routed = -1;
67 static gint ett_subn_directed_route = -1;
68 static gint ett_subnadmin = -1;
69 static gint ett_mad = -1;
70 static gint ett_cm = -1;
71 static gint ett_rmpp = -1;
72 static gint ett_subm_attribute = -1;
73 static gint ett_suba_attribute = -1;
74 static gint ett_datadetails = -1;
75 static gint ett_noticestraps = -1;
76 /* static gint ett_nodedesc = -1;                  */
77 /* static gint ett_nodeinfo = -1;                  */
78 /* static gint ett_switchinfo = -1;                */
79 /* static gint ett_guidinfo = -1;                  */
80 /* static gint ett_portinfo = -1;                  */
81 static gint ett_portinfo_capmask = -1;
82 static gint ett_pkeytable = -1;
83 static gint ett_sltovlmapping = -1;
84 static gint ett_vlarbitrationtable = -1;
85 static gint ett_linearforwardingtable = -1;
86 static gint ett_randomforwardingtable = -1;
87 static gint ett_multicastforwardingtable = -1;
88 static gint ett_sminfo = -1;
89 static gint ett_vendordiag = -1;
90 static gint ett_ledinfo = -1;
91 static gint ett_linkspeedwidthpairs = -1;
92 static gint ett_informinfo = -1;
93 static gint ett_linkrecord = -1;
94 static gint ett_servicerecord = -1;
95 static gint ett_pathrecord = -1;
96 static gint ett_mcmemberrecord = -1;
97 static gint ett_tracerecord = -1;
98 static gint ett_multipathrecord = -1;
99 static gint ett_serviceassocrecord = -1;
100 static gint ett_perfclass = -1;
101 static gint ett_eoib = -1;
102 static gint ett_link = -1;
103
104 /* Global ref to highest level tree should we find other protocols encapsulated in IB */
105 static proto_tree *top_tree = NULL;
106
107 /* Dissector Declarations */
108 static dissector_handle_t ipv6_handle;
109 static dissector_handle_t data_handle;
110 static dissector_handle_t eth_handle;
111 static dissector_table_t ethertype_dissector_table;
112
113 /* MAD_Data
114 * Structure to hold information from the common MAD header.
115 * This is necessary because the MAD header contains information which significantly changes the dissection algorithm. */
116 typedef struct {
117     guint8 managementClass;
118     guint8 classVersion;
119     guint8 method;
120     guint8 status;
121     guint16 classSpecific;
122     guint64 transactionID;
123     guint16 attributeID;
124     guint32 attributeModifier;
125     char data[232];
126 } MAD_Data;
127
128 /* Forward-declarations */
129
130 static void dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
131 static void dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
132 static void dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh);
133 static void dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
134 static gint32 find_next_header_sequence(guint32 OpCode);
135 static gboolean contains(guint32 value, guint32* arr, int length);
136 static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh);
137
138 /* Parsing Methods for specific IB headers. */
139
140 static void parse_VENDOR(proto_tree *, tvbuff_t *, gint *);
141 static void parse_PAYLOAD(proto_tree *, packet_info *, tvbuff_t *, gint *, gint length);
142 static void parse_IETH(proto_tree *, tvbuff_t *, gint *);
143 static void parse_IMMDT(proto_tree *, tvbuff_t *, gint *offset);
144 static void parse_ATOMICACKETH(proto_tree *, tvbuff_t *, gint *offset);
145 static void parse_AETH(proto_tree *, tvbuff_t *, gint *offset);
146 static void parse_ATOMICETH(proto_tree *, tvbuff_t *, gint *offset);
147 static void parse_RETH(proto_tree *, tvbuff_t *, gint *offset);
148 static void parse_DETH(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
149 static void parse_RDETH(proto_tree *, tvbuff_t *, gint *offset);
150 static void parse_IPvSix(proto_tree *, tvbuff_t *, gint *offset, packet_info *);
151 static void parse_RWH(proto_tree *, tvbuff_t *, gint *offset, packet_info *);
152 static gboolean parse_EoIB(proto_tree *, tvbuff_t *, gint offset, packet_info *);
153
154 static void parse_SUBN_LID_ROUTED(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
155 static void parse_SUBN_DIRECTED_ROUTE(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
156 static void parse_SUBNADMN(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
157 static void parse_PERF(proto_tree *, tvbuff_t *, packet_info *, gint *offset);
158 static void parse_BM(proto_tree *, tvbuff_t *, gint *offset);
159 static void parse_DEV_MGT(proto_tree *, tvbuff_t *, gint *offset);
160 static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset);
161 static void parse_SNMP(proto_tree *, tvbuff_t *, gint *offset);
162 static void parse_VENDOR_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
163 static void parse_APPLICATION_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
164 static void parse_RESERVED_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
165
166 static gboolean parse_MAD_Common(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
167 static gboolean parse_RMPP(proto_tree* , tvbuff_t* , gint *offset);
168 static void label_SUBM_Method(proto_item*, MAD_Data*, packet_info*);
169 static void label_SUBM_Attribute(proto_item*, MAD_Data*, packet_info*);
170 static void label_SUBA_Method(proto_item*, MAD_Data*, packet_info*);
171 static void label_SUBA_Attribute(proto_item*, MAD_Data*, packet_info*);
172
173 /* Class Attribute Parsing Routines */
174 static gboolean parse_SUBM_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
175 static gboolean parse_SUBA_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
176
177 /* These methods parse individual attributes
178 * Naming convention FunctionHandle = "parse_" + [Attribute Name];
179 * Where [Attribute Name] is the attribute identifier from chapter 14 of the IB Specification
180 * Subnet Management */
181 static void parse_NoticesAndTraps(proto_tree*, tvbuff_t*, gint *offset);
182 static void parse_NodeDescription(proto_tree*, tvbuff_t*, gint *offset);
183 static void parse_NodeInfo(proto_tree*, tvbuff_t*, gint *offset);
184 static void parse_SwitchInfo(proto_tree*, tvbuff_t*, gint *offset);
185 static void parse_GUIDInfo(proto_tree*, tvbuff_t*, gint *offset);
186 static void parse_PortInfo(proto_tree*, tvbuff_t*, gint *offset);
187 static void parse_P_KeyTable(proto_tree*, tvbuff_t*, gint *offset);
188 static void parse_SLtoVLMappingTable(proto_tree*, tvbuff_t*, gint *offset);
189 static void parse_VLArbitrationTable(proto_tree*, tvbuff_t*, gint *offset);
190 static void parse_LinearForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
191 static void parse_RandomForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
192 static void parse_MulticastForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
193 static void parse_SMInfo(proto_tree*, tvbuff_t*, gint *offset);
194 static void parse_VendorDiag(proto_tree*, tvbuff_t*, gint *offset);
195 static void parse_LedInfo(proto_tree*, tvbuff_t*, gint *offset);
196 static void parse_LinkSpeedWidthPairsTable(proto_tree*, tvbuff_t*, gint *offset);
197
198 /* These methods parse individual attributes for specific MAD management classes.
199 * Naming convention FunctionHandle = "parse_" + [Management Class] + "_" + [Attribute Name];
200 * Where [Management Class] is the shorthand name for the management class as defined
201 * in the MAD Management Classes section below in this file, and [Attribute Name] is the
202 * attribute identifier from the corresponding chapter of the IB Specification */
203 static void parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset);
204 static void parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset);
205
206 /* Subnet Administration */
207 static void parse_InformInfo(proto_tree*, tvbuff_t*, gint *offset);
208 static void parse_LinkRecord(proto_tree*, tvbuff_t*, gint *offset);
209 static void parse_ServiceRecord(proto_tree*, tvbuff_t*, gint *offset);
210 static void parse_PathRecord(proto_tree*, tvbuff_t*, gint *offset);
211 static void parse_MCMemberRecord(proto_tree*, tvbuff_t*, gint *offset);
212 static void parse_TraceRecord(proto_tree*, tvbuff_t*, gint *offset);
213 static void parse_MultiPathRecord(proto_tree*, tvbuff_t*, gint *offset);
214 static void parse_ServiceAssociationRecord(proto_tree*, tvbuff_t*, gint *offset);
215
216 /* Subnet Administration */
217 static void parse_RID(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
218
219 /* SM Methods */
220 static const value_string SUBM_Methods[] = {
221     { 0x01, "SubnGet("},
222     { 0x02, "SubnSet("},
223     { 0x81, "SubnGetResp("},
224     { 0x05, "SubnTrap("},
225     { 0x07, "SubnTrapResp("},
226     { 0, NULL}
227 };
228 /* SM Attributes */
229 static const value_string SUBM_Attributes[] = {
230     { 0x0001, "Attribute (ClassPortInfo)"},
231     { 0x0002, "Attribute (Notice)"},
232     { 0x0003, "Attribute (InformInfo)"},
233     { 0x0010, "Attribute (NodeDescription)"},
234     { 0x0011, "Attribute (NodeInfo)"},
235     { 0x0012, "Attribute (SwitchInfo)"},
236     { 0x0014, "Attribute (GUIDInfo)"},
237     { 0x0015, "Attribute (PortInfo)"},
238     { 0x0016, "Attribute (P_KeyTable)"},
239     { 0x0017, "Attribute (SLtoVLMapptingTable)"},
240     { 0x0018, "Attribute (VLArbitrationTable)"},
241     { 0x0019, "Attribute (LinearForwardingTable)"},
242     { 0x001A, "Attribute (RandomForwardingTable)"},
243     { 0x001B, "Attribute (MulticastForwardingTable)"},
244     { 0x001C, "Attribute (LinkSpeedWidthPairsTable)"},
245     { 0x0020, "Attribute (SMInfo)"},
246     { 0x0030, "Attribute (VendorDiag)"},
247     { 0x0031, "Attribute (LedInfo)"},
248     { 0, NULL}
249 };
250
251 /* SA Methods */
252 static const value_string SUBA_Methods[] = {
253     { 0x01, "SubnAdmGet("},
254     { 0x81, "SubnAdmGetResp("},
255     { 0x02, "SubnAdmSet("},
256     { 0x06, "SubnAdmReport("},
257     { 0x86, "SubnAdmReportResp("},
258     { 0x12, "SubnAdmGetTable("},
259     { 0x92, "SubnAdmGetTableResp("},
260     { 0x13, "SubnAdmGetTraceTable("},
261     { 0x14, "SubnAdmGetMulti("},
262     { 0x94, "SubnAdmGetMultiResp("},
263     { 0x15, "SubnAdmDelete("},
264     { 0x95, "SubnAdmDeleteResp("},
265     { 0, NULL}
266 };
267 /* SA Attributes */
268 static const value_string SUBA_Attributes[] = {
269     { 0x0001, "Attribute (ClassPortInfo)"},
270     { 0x0002, "Attribute (Notice)"},
271     { 0x0003, "Attribute (InformInfo)"},
272     { 0x0011, "Attribute (NodeRecord)"},
273     { 0x0012, "Attribute (PortInfoRecord)"},
274     { 0x0013, "Attribute (SLtoVLMappingTableRecord)"},
275     { 0x0014, "Attribute (SwitchInfoRecord)"},
276     { 0x0015, "Attribute (LinearForwardingTableRecord)"},
277     { 0x0016, "Attribute (RandomForwardingTableRecord)"},
278     { 0x0017, "Attribute (MulticastForwardingTableRecord)"},
279     { 0x0018, "Attribute (SMInfoRecord)"},
280     { 0x0019, "Attribute (LinkSpeedWidthPairsTableRecord)"},
281     { 0x00F3, "Attribute (InformInfoRecord)"},
282     { 0x0020, "Attribute (LinkRecord)"},
283     { 0x0030, "Attribute (GuidInfoRecord)"},
284     { 0x0031, "Attribute (ServiceRecord)"},
285     { 0x0033, "Attribute (P_KeyTableRecord)"},
286     { 0x0035, "Attribute (PathRecord)"},
287     { 0x0036, "Attribute (VLArbitrationTableRecord)"},
288     { 0x0038, "Attribute (MCMembersRecord)"},
289     { 0x0039, "Attribute (TraceRecord)"},
290     { 0x003A, "Attribute (MultiPathRecord)"},
291     { 0x003B, "Attribute (ServiceAssociationRecord)"},
292     { 0, NULL}
293 };
294
295 /* CM Attributes */
296 static const value_string CM_Attributes[] = {
297     { 0x0001, "ClassPortInfo"},
298     { 0x0010, "ConnectRequest"},
299     { 0x0011, "MsgRcptAck"},
300     { 0x0012, "ConnectReject"},
301     { 0x0013, "ConnectReply"},
302     { 0x0014, "ReadyToUse"},
303     { 0x0015, "DisconnectRequest"},
304     { 0x0016, "DisconnectReply"},
305     { 0x0017, "ServiceIDResReq"},
306     { 0x0018, "ServiceIDResReqResp"},
307     { 0x0019, "LoadAlternatePath"},
308     { 0x001A, "AlternatePathResponse"},
309     { 0, NULL}
310 };
311
312
313 /* RMPP Types */
314 #define RMPP_ILLEGAL 0
315 #define RMPP_DATA   1
316 #define RMPP_ACK    2
317 #define RMPP_STOP   3
318 #define RMPP_ABORT  4
319
320 static const value_string RMPP_Packet_Types[] = {
321     { RMPP_ILLEGAL, " Illegal RMPP Type (0)! " },
322     { RMPP_DATA, "RMPP (DATA)" },
323     { RMPP_ACK, "RMPP (ACK)" },
324     { RMPP_STOP, "RMPP (STOP)" },
325     { RMPP_ABORT, "RMPP (ABORT)" },
326     { 0, NULL}
327 };
328
329 static const value_string RMPP_Flags[] = {
330     { 3, " (Transmission Sequence - First Packet)"},
331     { 5, " (Transmission Sequence - Last Packet)"},
332     { 1, " (Transmission Sequence) " },
333     { 0, NULL}
334 };
335
336 static const value_string RMPP_Status[]= {
337     { 0, " (Normal)"},
338     { 1, " (Resources Exhausted)"},
339     { 118, " (Total Time Too Long)"},
340     { 119, " (Inconsistent Last and PayloadLength)"},
341     { 120, " (Inconsistent First and Segment Number)"},
342     { 121, " (Bad RMPPType)"},
343     { 122, " (NewWindowLast Too Small)"},
344     { 123, " (SegmentNumber Too Big)"},
345     { 124, " (Illegal Status)"},
346     { 125, " (Unsupported Version)"},
347     { 126, " (Too Many Retries)"},
348     { 127, " (Unspecified - Unknown Error Code on ABORT)"},
349     { 0, NULL}
350 };
351
352 static const value_string DiagCode[]= {
353     {0x0000, "Function Ready"},
354     {0x0001, "Performing Self Test"},
355     {0x0002, "Initializing"},
356     {0x0003, "Soft Error - Function has non-fatal error"},
357     {0x0004, "Hard Error - Function has fatal error"},
358     { 0, NULL}
359 };
360 static const value_string LinkWidthEnabled[]= {
361     {0x0000, "No State Change"},
362     {0x0001, "1x"},
363     {0x0002, "4x"},
364     {0x0003, "1x or 4x"},
365     {0x0004, "8x"},
366     {0x0005, "1x or 8x"},
367     {0x0006, "4x or 8x"},
368     {0x0007, "1x or 4x or 8x"},
369     {0x0008, "12x"},
370     {0x0009, "1x or 12x"},
371     {0x000A, "4x or 12x"},
372     {0x000B, "1x or 4x or 12x"},
373     {0x000C, "8x or 12x"},
374     {0x000D, "1x or 8x or 12x"},
375     {0x000E, "4x or 8x or 12x"},
376     {0x000E, "1x or 4x or 8x or 12x"},
377     {0x00FF, "Set to LinkWidthSupported Value - Response contains actual LinkWidthSupported"},
378     { 0, NULL}
379 };
380
381 static const value_string LinkWidthSupported[]= {
382     {0x0001, "1x"},
383     {0x0003, "1x or 4x"},
384     {0x0007, "1x or 4x or 8x"},
385     {0x000B, "1x or 4x or 12x"},
386     {0x000F, "1x or 4x or 8x or 12x"},
387     { 0, NULL}
388 };
389 static const value_string LinkWidthActive[]= {
390     {0x0001, "1x"},
391     {0x0002, "4x"},
392     {0x0004, "8x"},
393     {0x0008, "12x"},
394     { 0, NULL}
395 };
396 static const value_string LinkSpeedSupported[]= {
397     {0x0001, "2.5 Gbps"},
398     {0x0003, "2.5 or 5.0 Gbps"},
399     {0x0005, "2.5 or 10.0 Gbps"},
400     {0x0007, "2.5 or 5.0 or 10.0 Gbps"},
401     { 0, NULL}
402 };
403 static const value_string PortState[]= {
404     {0x0000, "No State Change"},
405     {0x0001, "Down (includes failed links)"},
406     {0x0002, "Initialized"},
407     {0x0003, "Armed"},
408     {0x0004, "Active"},
409     { 0, NULL}
410 };
411 static const value_string PortPhysicalState[]= {
412     {0x0000, "No State Change"},
413     {0x0001, "Sleep"},
414     {0x0002, "Polling"},
415     {0x0003, "Disabled"},
416     {0x0004, "PortConfigurationTraining"},
417     {0x0005, "LinkUp"},
418     {0x0006, "LinkErrorRecovery"},
419     {0x0007, "Phy Test"},
420     { 0, NULL}
421 };
422 static const value_string LinkDownDefaultState[]= {
423     {0x0000, "No State Change"},
424     {0x0001, "Sleep"},
425     {0x0002, "Polling"},
426     { 0, NULL}
427 };
428 static const value_string LinkSpeedActive[]= {
429     {0x0001, "2.5 Gbps"},
430     {0x0002, "5.0 Gbps"},
431     {0x0004, "10.0 Gbps"},
432     { 0, NULL}
433 };
434 static const value_string LinkSpeedEnabled[]= {
435     {0x0000, "No State Change"},
436     {0x0001, "2.5 Gbps"},
437     {0x0003, "2.5 or 5.0 Gbps"},
438     {0x0005, "2.5 or 10.0 Gbps"},
439     {0x0007, "2.5 or 5.0 or 10.0 Gbps"},
440     {0x000F, "Set to LinkSpeedSupported value - response contains actual LinkSpeedSupported"},
441     { 0, NULL}
442 };
443 static const value_string NeighborMTU[]= {
444     {0x0001, "256"},
445     {0x0002, "512"},
446     {0x0003, "1024"},
447     {0x0004, "2048"},
448     {0x0005, "4096"},
449     { 0, NULL}
450 };
451 static const value_string VLCap[]= {
452     {0x0001, "VL0"},
453     {0x0002, "VL0, VL1"},
454     {0x0003, "VL0 - VL3"},
455     {0x0004, "VL0 - VL7"},
456     {0x0005, "VL0 - VL14"},
457     { 0, NULL}
458 };
459 static const value_string MTUCap[]= {
460     {0x0001, "256"},
461     {0x0002, "512"},
462     {0x0003, "1024"},
463     {0x0004, "2048"},
464     {0x0005, "4096"},
465     { 0, NULL}
466 };
467 static const value_string OperationalVLs[]= {
468     {0x0000, "No State Change"},
469     {0x0001, "VL0"},
470     {0x0002, "VL0, VL1"},
471     {0x0003, "VL0 - VL3"},
472     {0x0004, "VL0 - VL7"},
473     {0x0005, "VL0 - VL14"},
474     { 0, NULL}
475 };
476
477 /* Local Route Header (LRH) */
478 static int hf_infiniband_LRH = -1;
479 static int hf_infiniband_virtual_lane = -1;
480 static int hf_infiniband_link_version = -1;
481 static int hf_infiniband_service_level = -1;
482 static int hf_infiniband_reserved2 = -1;
483 static int hf_infiniband_link_next_header = -1;
484 static int hf_infiniband_destination_local_id = -1;
485 static int hf_infiniband_reserved5 = -1;
486 static int hf_infiniband_packet_length = -1;
487 static int hf_infiniband_source_local_id = -1;
488 /* Global Route Header (GRH) */
489 static int hf_infiniband_GRH = -1;
490 static int hf_infiniband_ip_version = -1;
491 static int hf_infiniband_traffic_class = -1;
492 static int hf_infiniband_flow_label = -1;
493 static int hf_infiniband_payload_length = -1;
494 static int hf_infiniband_next_header = -1;
495 static int hf_infiniband_hop_limit = -1;
496 static int hf_infiniband_source_gid = -1;
497 static int hf_infiniband_destination_gid = -1;
498 /* Base Transport Header (BTH) */
499 static int hf_infiniband_BTH = -1;
500 static int hf_infiniband_opcode = -1;
501 static int hf_infiniband_solicited_event = -1;
502 static int hf_infiniband_migreq = -1;
503 static int hf_infiniband_pad_count = -1;
504 static int hf_infiniband_transport_header_version = -1;
505 static int hf_infiniband_partition_key = -1;
506 static int hf_infiniband_reserved8 = -1;
507 static int hf_infiniband_destination_qp = -1;
508 static int hf_infiniband_acknowledge_request = -1;
509 static int hf_infiniband_reserved7 = -1;
510 static int hf_infiniband_packet_sequence_number = -1;
511 /* Raw Header (RWH) */
512 static int hf_infiniband_RWH = -1;
513 static int hf_infiniband_reserved16_RWH = -1;
514 static int hf_infiniband_etype = -1;
515 /* Reliable Datagram Extended Transport Header (RDETH) */
516 static int hf_infiniband_RDETH = -1;
517 static int hf_infiniband_reserved8_RDETH = -1;
518 static int hf_infiniband_ee_context = -1;
519 /* Datagram Extended Transport Header (DETH) */
520 static int hf_infiniband_DETH = -1;
521 static int hf_infiniband_queue_key = -1;
522 static int hf_infiniband_reserved8_DETH = -1;
523 static int hf_infiniband_source_qp = -1;
524 /* RDMA Extended Transport Header (RETH) */
525 static int hf_infiniband_RETH = -1;
526 static int hf_infiniband_virtual_address = -1;
527 static int hf_infiniband_remote_key = -1;
528 static int hf_infiniband_dma_length = -1;
529 /* Atomic Extended Transport Header (AtomicETH) */
530 static int hf_infiniband_AtomicETH = -1;
531 /* static int hf_infiniband_virtual_address_AtomicETH = -1;                  */
532 /* static int hf_infiniband_remote_key_AtomicETH = -1;                       */
533 static int hf_infiniband_swap_or_add_data = -1;
534 static int hf_infiniband_compare_data = -1;
535 /* ACK Extended Transport Header (AETH) */
536 static int hf_infiniband_AETH = -1;
537 static int hf_infiniband_syndrome = -1;
538 static int hf_infiniband_message_sequence_number = -1;
539 /* Atomic ACK Extended Transport Header (AtomicAckETH) */
540 static int hf_infiniband_AtomicAckETH = -1;
541 static int hf_infiniband_original_remote_data = -1;
542 /* Immediate Extended Transport Header (ImmDt) */
543 static int hf_infiniband_IMMDT = -1;
544 /* Invalidate Extended Transport Header (IETH) */
545 static int hf_infiniband_IETH = -1;
546 /* Payload */
547 static int hf_infiniband_payload = -1;
548 static int hf_infiniband_invariant_crc = -1;
549 static int hf_infiniband_variant_crc = -1;
550 /* Unknown or Vendor Specific */
551 static int hf_infiniband_raw_data = -1;
552 static int hf_infiniband_vendor = -1;
553 /* CM REQ Header */
554 static int hf_cm_req_local_comm_id = -1;
555 static int hf_cm_req_service_id = -1;
556 static int hf_cm_req_local_ca_guid = -1;
557 static int hf_cm_req_local_qkey = -1;
558 static int hf_cm_req_local_qpn = -1;
559 static int hf_cm_req_respo_res = -1;
560 static int hf_cm_req_local_eecn = -1;
561 static int hf_cm_req_init_depth = -1;
562 static int hf_cm_req_remote_eecn = -1;
563 static int hf_cm_req_remote_cm_resp_to = -1;
564 static int hf_cm_req_transp_serv_type = -1;
565 static int hf_cm_req_e2e_flow_ctrl = -1;
566 static int hf_cm_req_start_psn = -1;
567 static int hf_cm_req_local_cm_resp_to = -1;
568 static int hf_cm_req_retry_count = -1;
569 static int hf_cm_req_pkey = -1;
570 static int hf_cm_req_path_pp_mtu = -1;
571 static int hf_cm_req_rdc_exists = -1;
572 static int hf_cm_req_rnr_retry_count = -1;
573 static int hf_cm_req_max_cm_retries = -1;
574 static int hf_cm_req_srq = -1;
575 static int hf_cm_req_primary_local_lid = -1;
576 static int hf_cm_req_primary_remote_lid = -1;
577 static int hf_cm_req_primary_local_gid = -1;
578 static int hf_cm_req_primary_remote_gid = -1;
579 static int hf_cm_req_primary_flow_label = -1;
580 static int hf_cm_req_primary_packet_rate = -1;
581 static int hf_cm_req_primary_traffic_class = -1;
582 static int hf_cm_req_primary_hop_limit = -1;
583 static int hf_cm_req_primary_sl = -1;
584 static int hf_cm_req_primary_subnet_local = -1;
585 static int hf_cm_req_primary_local_ack_to = -1;
586 static int hf_cm_req_alt_local_lid = -1;
587 static int hf_cm_req_alt_remote_lid = -1;
588 static int hf_cm_req_alt_local_gid = -1;
589 static int hf_cm_req_alt_remote_gid = -1;
590 static int hf_cm_req_flow_label = -1;
591 static int hf_cm_req_packet_rate = -1;
592 static int hf_cm_req_alt_traffic_class = -1;
593 static int hf_cm_req_alt_hop_limit = -1;
594 static int hf_cm_req_SL = -1;
595 static int hf_cm_req_subnet_local = -1;
596 static int hf_cm_req_local_ACK_timeout = -1;
597 static int hf_cm_req_private_data = -1;
598 /* CM REP Header */
599 static int hf_cm_rep_localcommid = -1;
600 static int hf_cm_rep_remotecommid = -1;
601 static int hf_cm_rep_localqkey = -1;
602 static int hf_cm_rep_localqpn = -1;
603 static int hf_cm_rep_localeecontnum = -1;
604 static int hf_cm_rep_startingpsn = -1;
605 static int hf_cm_rep_responderres = -1;
606 static int hf_cm_rep_initiatordepth = -1;
607 static int hf_cm_rep_tgtackdelay = -1;
608 static int hf_cm_rep_failoveracc = -1;
609 static int hf_cm_rep_e2eflowctl = -1;
610 static int hf_cm_rep_rnrretrycount = -1;
611 static int hf_cm_rep_srq = -1;
612 static int hf_cm_rep_localcaguid = -1;
613 static int hf_cm_rep_privatedata = -1;
614 /* CM RTU Header */
615 static int hf_cm_rtu_localcommid = -1;
616 static int hf_cm_rtu_remotecommid = -1;
617 static int hf_cm_rtu_privatedata = -1;
618 /* CM REJ Header */
619 static int hf_cm_rej_local_commid = -1;
620 static int hf_cm_rej_remote_commid = -1;
621 static int hf_cm_rej_msg_rej = -1;
622 static int hf_cm_rej_rej_info_len = -1;
623 static int hf_cm_rej_reason = -1;
624 static int hf_cm_rej_add_rej_info = -1;
625 static int hf_cm_rej_private_data = -1;
626 /* MAD Base Header */
627 static int hf_infiniband_MAD = -1;
628 static int hf_infiniband_base_version = -1;
629 static int hf_infiniband_mgmt_class = -1;
630 static int hf_infiniband_class_version = -1;
631 /* static int hf_infiniband_reserved1 = -1;                                  */
632 static int hf_infiniband_method = -1;
633 static int hf_infiniband_status = -1;
634 static int hf_infiniband_class_specific = -1;
635 static int hf_infiniband_transaction_id = -1;
636 static int hf_infiniband_attribute_id = -1;
637 static int hf_infiniband_reserved16 = -1;
638 static int hf_infiniband_attribute_modifier = -1;
639 static int hf_infiniband_data = -1;
640 /* RMPP Header */
641 static int hf_infiniband_RMPP = -1;
642 static int hf_infiniband_rmpp_version = -1;
643 static int hf_infiniband_rmpp_type = -1;
644 static int hf_infiniband_r_resp_time = -1;
645 static int hf_infiniband_rmpp_flags = -1;
646 static int hf_infiniband_rmpp_status = -1;
647 static int hf_infiniband_rmpp_data1 = -1;
648 static int hf_infiniband_rmpp_data2 = -1;
649 /* RMPP Data */
650 /* static int hf_infiniband_RMPP_DATA = -1;                                  */
651 static int hf_infiniband_segment_number = -1;
652 static int hf_infiniband_payload_length32 = -1;
653 static int hf_infiniband_transferred_data = -1;
654 /* RMPP ACK */
655 static int hf_infiniband_new_window_last = -1;
656 static int hf_infiniband_reserved220 = -1;
657 /* RMPP ABORT and STOP */
658 static int hf_infiniband_reserved32 = -1;
659 static int hf_infiniband_optional_extended_error_data = -1;
660 /* SMP Data LID Routed */
661 static int hf_infiniband_SMP_LID = -1;
662 static int hf_infiniband_m_key = -1;
663 static int hf_infiniband_smp_data = -1;
664 static int hf_infiniband_reserved1024 = -1;
665 static int hf_infiniband_reserved256 = -1;
666 /* SMP Data Directed Route */
667 static int hf_infiniband_SMP_DIRECTED = -1;
668 static int hf_infiniband_smp_status = -1;
669 static int hf_infiniband_hop_pointer = -1;
670 static int hf_infiniband_hop_count = -1;
671 static int hf_infiniband_dr_slid = -1;
672 static int hf_infiniband_dr_dlid = -1;
673 static int hf_infiniband_reserved28 = -1;
674 static int hf_infiniband_d = -1;
675 static int hf_infiniband_initial_path = -1;
676 static int hf_infiniband_return_path = -1;
677 /* SA MAD Header */
678 static int hf_infiniband_SA = -1;
679 static int hf_infiniband_sm_key = -1;
680 static int hf_infiniband_attribute_offset = -1;
681 static int hf_infiniband_component_mask = -1;
682 static int hf_infiniband_subnet_admin_data = -1;
683 /* Mellanox EoIB encapsulation header */
684 static int hf_infiniband_EOIB = -1;
685 static int hf_infiniband_ver = -1;
686 static int hf_infiniband_tcp_chk = -1;
687 static int hf_infiniband_ip_chk = -1;
688 static int hf_infiniband_fcs = -1;
689 static int hf_infiniband_ms = -1;
690 static int hf_infiniband_seg_off = -1;
691 static int hf_infiniband_seg_id = -1;
692
693 /* Attributes
694 * Additional Structures for individuala attribute decoding.
695 * Since they are not headers the naming convention is slightly modified
696 * Convention: hf_infiniband_[attribute name]_[field]
697 * This was not entirely necessary but I felt the previous convention
698 * did not provide adequate readability for the granularity of attribute/attribute fields. */
699
700 /* NodeDescription */
701 static int hf_infiniband_NodeDescription_NodeString = -1;
702 /* NodeInfo */
703 static int hf_infiniband_NodeInfo_BaseVersion = -1;
704 static int hf_infiniband_NodeInfo_ClassVersion = -1;
705 static int hf_infiniband_NodeInfo_NodeType = -1;
706 static int hf_infiniband_NodeInfo_NumPorts = -1;
707 static int hf_infiniband_NodeInfo_SystemImageGUID = -1;
708 static int hf_infiniband_NodeInfo_NodeGUID = -1;
709 static int hf_infiniband_NodeInfo_PortGUID = -1;
710 static int hf_infiniband_NodeInfo_PartitionCap = -1;
711 static int hf_infiniband_NodeInfo_DeviceID = -1;
712 static int hf_infiniband_NodeInfo_Revision = -1;
713 static int hf_infiniband_NodeInfo_LocalPortNum = -1;
714 static int hf_infiniband_NodeInfo_VendorID = -1;
715 /* SwitchInfo */
716 static int hf_infiniband_SwitchInfo_LinearFDBCap = -1;
717 static int hf_infiniband_SwitchInfo_RandomFDBCap = -1;
718 static int hf_infiniband_SwitchInfo_MulticastFDBCap = -1;
719 static int hf_infiniband_SwitchInfo_LinearFDBTop = -1;
720 static int hf_infiniband_SwitchInfo_DefaultPort = -1;
721 static int hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort = -1;
722 static int hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort = -1;
723 static int hf_infiniband_SwitchInfo_LifeTimeValue = -1;
724 static int hf_infiniband_SwitchInfo_PortStateChange = -1;
725 static int hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming = -1;
726 static int hf_infiniband_SwitchInfo_LIDsPerPort = -1;
727 static int hf_infiniband_SwitchInfo_PartitionEnforcementCap = -1;
728 static int hf_infiniband_SwitchInfo_InboundEnforcementCap = -1;
729 static int hf_infiniband_SwitchInfo_OutboundEnforcementCap = -1;
730 static int hf_infiniband_SwitchInfo_FilterRawInboundCap = -1;
731 static int hf_infiniband_SwitchInfo_FilterRawOutboundCap = -1;
732 static int hf_infiniband_SwitchInfo_EnhancedPortZero = -1;
733 /* GUIDInfo */
734 /* static int hf_infiniband_GUIDInfo_GUIDBlock = -1;                         */
735 static int hf_infiniband_GUIDInfo_GUID = -1;
736 /* PortInfo */
737 static int hf_infiniband_PortInfo_GidPrefix = -1;
738 static int hf_infiniband_PortInfo_LID = -1;
739 static int hf_infiniband_PortInfo_MasterSMLID = -1;
740 static int hf_infiniband_PortInfo_CapabilityMask = -1;
741
742 /* Capability Mask Flags */
743 static int hf_infiniband_PortInfo_CapabilityMask_SM = -1;
744 static int hf_infiniband_PortInfo_CapabilityMask_NoticeSupported = -1;
745 static int hf_infiniband_PortInfo_CapabilityMask_TrapSupported = -1;
746 static int hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported = -1;
747 static int hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported = -1;
748 static int hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported = -1;
749 static int hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM = -1;
750 static int hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM = -1;
751 static int hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported = -1;
752 static int hf_infiniband_PortInfo_CapabilityMask_SMdisabled = -1;
753 static int hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported = -1;
754 static int hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported = -1;
755 static int hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported = -1;
756 static int hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported = -1;
757 static int hf_infiniband_PortInfo_CapabilityMask_ReinitSupported = -1;
758 static int hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported = -1;
759 static int hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported = -1;
760 static int hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported = -1;
761 static int hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported = -1;
762 static int hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported = -1;
763 static int hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported = -1;
764 static int hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported = -1;
765 static int hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported = -1;
766 static int hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported = -1;
767 /* End Capability Mask Flags */
768
769
770 static int hf_infiniband_PortInfo_DiagCode = -1;
771 static int hf_infiniband_PortInfo_M_KeyLeasePeriod = -1;
772 static int hf_infiniband_PortInfo_LocalPortNum = -1;
773 static int hf_infiniband_PortInfo_LinkWidthEnabled = -1;
774 static int hf_infiniband_PortInfo_LinkWidthSupported = -1;
775 static int hf_infiniband_PortInfo_LinkWidthActive = -1;
776 static int hf_infiniband_PortInfo_LinkSpeedSupported = -1;
777 static int hf_infiniband_PortInfo_PortState = -1;
778 static int hf_infiniband_PortInfo_PortPhysicalState = -1;
779 static int hf_infiniband_PortInfo_LinkDownDefaultState = -1;
780 static int hf_infiniband_PortInfo_M_KeyProtectBits = -1;
781 static int hf_infiniband_PortInfo_LMC = -1;
782 static int hf_infiniband_PortInfo_LinkSpeedActive = -1;
783 static int hf_infiniband_PortInfo_LinkSpeedEnabled = -1;
784 static int hf_infiniband_PortInfo_NeighborMTU = -1;
785 static int hf_infiniband_PortInfo_MasterSMSL = -1;
786 static int hf_infiniband_PortInfo_VLCap = -1;
787 static int hf_infiniband_PortInfo_M_Key = -1;
788 static int hf_infiniband_PortInfo_InitType = -1;
789 static int hf_infiniband_PortInfo_VLHighLimit = -1;
790 static int hf_infiniband_PortInfo_VLArbitrationHighCap = -1;
791 static int hf_infiniband_PortInfo_VLArbitrationLowCap = -1;
792 static int hf_infiniband_PortInfo_InitTypeReply = -1;
793 static int hf_infiniband_PortInfo_MTUCap = -1;
794 static int hf_infiniband_PortInfo_VLStallCount = -1;
795 static int hf_infiniband_PortInfo_HOQLife = -1;
796 static int hf_infiniband_PortInfo_OperationalVLs = -1;
797 static int hf_infiniband_PortInfo_PartitionEnforcementInbound = -1;
798 static int hf_infiniband_PortInfo_PartitionEnforcementOutbound = -1;
799 static int hf_infiniband_PortInfo_FilterRawInbound = -1;
800 static int hf_infiniband_PortInfo_FilterRawOutbound = -1;
801 static int hf_infiniband_PortInfo_M_KeyViolations = -1;
802 static int hf_infiniband_PortInfo_P_KeyViolations = -1;
803 static int hf_infiniband_PortInfo_Q_KeyViolations = -1;
804 static int hf_infiniband_PortInfo_GUIDCap = -1;
805 static int hf_infiniband_PortInfo_ClientReregister = -1;
806 static int hf_infiniband_PortInfo_SubnetTimeOut = -1;
807 static int hf_infiniband_PortInfo_RespTimeValue = -1;
808 static int hf_infiniband_PortInfo_LocalPhyErrors = -1;
809 static int hf_infiniband_PortInfo_OverrunErrors = -1;
810 static int hf_infiniband_PortInfo_MaxCreditHint = -1;
811 static int hf_infiniband_PortInfo_LinkRoundTripLatency = -1;
812
813 /* P_KeyTable */
814 static int hf_infiniband_P_KeyTable_P_KeyTableBlock = -1;
815 static int hf_infiniband_P_KeyTable_MembershipType = -1;
816 static int hf_infiniband_P_KeyTable_P_KeyBase = -1;
817
818 /* SLtoVLMappingTable */
819 static int hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits = -1;
820 static int hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits = -1;
821
822 /* VLArbitrationTable */
823 /* static int hf_infiniband_VLArbitrationTable_VLWeightPairs = -1;           */
824 static int hf_infiniband_VLArbitrationTable_VL = -1;
825 static int hf_infiniband_VLArbitrationTable_Weight = -1;
826
827 /* LinearForwardingTable */
828 /* static int hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock = -1;  */
829 static int hf_infiniband_LinearForwardingTable_Port = -1;
830
831 /* RandomForwardingTable */
832 /* static int hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock = -1;  */
833 static int hf_infiniband_RandomForwardingTable_LID = -1;
834 static int hf_infiniband_RandomForwardingTable_Valid = -1;
835 static int hf_infiniband_RandomForwardingTable_LMC = -1;
836 static int hf_infiniband_RandomForwardingTable_Port = -1;
837
838 /* MulticastForwardingTable */
839 /* static int hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock = -1;    */
840 static int hf_infiniband_MulticastForwardingTable_PortMask = -1;
841
842 /* SMInfo */
843 static int hf_infiniband_SMInfo_GUID = -1;
844 static int hf_infiniband_SMInfo_SM_Key = -1;
845 static int hf_infiniband_SMInfo_ActCount = -1;
846 static int hf_infiniband_SMInfo_Priority = -1;
847 static int hf_infiniband_SMInfo_SMState = -1;
848
849 /* VendorDiag */
850 static int hf_infiniband_VendorDiag_NextIndex = -1;
851 static int hf_infiniband_VendorDiag_DiagData = -1;
852
853 /* LedInfo */
854 static int hf_infiniband_LedInfo_LedMask = -1;
855
856 /* LinkSpeedWidthPairsTable */
857 static int hf_infiniband_LinkSpeedWidthPairsTable_NumTables = -1;
858 static int hf_infiniband_LinkSpeedWidthPairsTable_PortMask = -1;
859 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive = -1;
860 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive = -1;
861 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen = -1;
862
863 /* Attributes for Subnet Administration.
864 * Mostly we have "Records" here which are just structures of SM attributes.
865 * There are some unique attributes though that we will want to have a structure for. */
866
867 /* NodeRecord */
868 /* PortInfoRecord */
869 /* SLtoVLMappingTableRecord */
870 /* SwitchInfoRecord */
871 /* LinearForwardingTableRecord */
872 /* RandomForwardingTableRecord */
873 /* MulticastForwardingTableRecord */
874 /* VLArbitrationTableRecord */
875
876 static int hf_infiniband_SA_LID = -1;
877 static int hf_infiniband_SA_EndportLID = -1;
878 static int hf_infiniband_SA_PortNum = -1;
879 static int hf_infiniband_SA_InputPortNum = -1;
880 static int hf_infiniband_SA_OutputPortNum = -1;
881 static int hf_infiniband_SA_BlockNum_EightBit = -1;
882 static int hf_infiniband_SA_BlockNum_NineBit = -1;
883 static int hf_infiniband_SA_BlockNum_SixteenBit = -1;
884 static int hf_infiniband_SA_Position = -1;
885 /* static int hf_infiniband_SA_Index = -1;                                   */
886
887 /* InformInfoRecord */
888 static int hf_infiniband_InformInfoRecord_SubscriberGID = -1;
889 static int hf_infiniband_InformInfoRecord_Enum = -1;
890
891 /* InformInfo */
892 static int hf_infiniband_InformInfo_GID = -1;
893 static int hf_infiniband_InformInfo_LIDRangeBegin = -1;
894 static int hf_infiniband_InformInfo_LIDRangeEnd = -1;
895 static int hf_infiniband_InformInfo_IsGeneric = -1;
896 static int hf_infiniband_InformInfo_Subscribe = -1;
897 static int hf_infiniband_InformInfo_Type = -1;
898 static int hf_infiniband_InformInfo_TrapNumberDeviceID = -1;
899 static int hf_infiniband_InformInfo_QPN = -1;
900 static int hf_infiniband_InformInfo_RespTimeValue = -1;
901 static int hf_infiniband_InformInfo_ProducerTypeVendorID = -1;
902
903 /* LinkRecord */
904 static int hf_infiniband_LinkRecord_FromLID = -1;
905 static int hf_infiniband_LinkRecord_FromPort = -1;
906 static int hf_infiniband_LinkRecord_ToPort = -1;
907 static int hf_infiniband_LinkRecord_ToLID = -1;
908
909 /* ServiceRecord */
910 static int hf_infiniband_ServiceRecord_ServiceID = -1;
911 static int hf_infiniband_ServiceRecord_ServiceGID = -1;
912 static int hf_infiniband_ServiceRecord_ServiceP_Key = -1;
913 static int hf_infiniband_ServiceRecord_ServiceLease = -1;
914 static int hf_infiniband_ServiceRecord_ServiceKey = -1;
915 static int hf_infiniband_ServiceRecord_ServiceName = -1;
916 static int hf_infiniband_ServiceRecord_ServiceData = -1;
917
918 /* ServiceAssociationRecord */
919 static int hf_infiniband_ServiceAssociationRecord_ServiceKey = -1;
920 static int hf_infiniband_ServiceAssociationRecord_ServiceName = -1;
921
922 /* PathRecord */
923 static int hf_infiniband_PathRecord_DGID = -1;
924 static int hf_infiniband_PathRecord_SGID = -1;
925 static int hf_infiniband_PathRecord_DLID = -1;
926 static int hf_infiniband_PathRecord_SLID = -1;
927 static int hf_infiniband_PathRecord_RawTraffic = -1;
928 static int hf_infiniband_PathRecord_FlowLabel = -1;
929 static int hf_infiniband_PathRecord_HopLimit = -1;
930 static int hf_infiniband_PathRecord_TClass = -1;
931 static int hf_infiniband_PathRecord_Reversible = -1;
932 static int hf_infiniband_PathRecord_NumbPath = -1;
933 static int hf_infiniband_PathRecord_P_Key = -1;
934 static int hf_infiniband_PathRecord_SL = -1;
935 static int hf_infiniband_PathRecord_MTUSelector = -1;
936 static int hf_infiniband_PathRecord_MTU = -1;
937 static int hf_infiniband_PathRecord_RateSelector = -1;
938 static int hf_infiniband_PathRecord_Rate = -1;
939 static int hf_infiniband_PathRecord_PacketLifeTimeSelector = -1;
940 static int hf_infiniband_PathRecord_PacketLifeTime = -1;
941 static int hf_infiniband_PathRecord_Preference = -1;
942
943 /* MCMemberRecord */
944 static int hf_infiniband_MCMemberRecord_MGID = -1;
945 static int hf_infiniband_MCMemberRecord_PortGID = -1;
946 static int hf_infiniband_MCMemberRecord_Q_Key = -1;
947 static int hf_infiniband_MCMemberRecord_MLID = -1;
948 static int hf_infiniband_MCMemberRecord_MTUSelector = -1;
949 static int hf_infiniband_MCMemberRecord_MTU = -1;
950 static int hf_infiniband_MCMemberRecord_TClass = -1;
951 static int hf_infiniband_MCMemberRecord_P_Key = -1;
952 static int hf_infiniband_MCMemberRecord_RateSelector = -1;
953 static int hf_infiniband_MCMemberRecord_Rate = -1;
954 static int hf_infiniband_MCMemberRecord_PacketLifeTimeSelector = -1;
955 static int hf_infiniband_MCMemberRecord_PacketLifeTime = -1;
956 static int hf_infiniband_MCMemberRecord_SL = -1;
957 static int hf_infiniband_MCMemberRecord_FlowLabel = -1;
958 static int hf_infiniband_MCMemberRecord_HopLimit = -1;
959 static int hf_infiniband_MCMemberRecord_Scope = -1;
960 static int hf_infiniband_MCMemberRecord_JoinState = -1;
961 static int hf_infiniband_MCMemberRecord_ProxyJoin = -1;
962
963 /* TraceRecord */
964 static int hf_infiniband_TraceRecord_GIDPrefix = -1;
965 static int hf_infiniband_TraceRecord_IDGeneration = -1;
966 static int hf_infiniband_TraceRecord_NodeType = -1;
967 static int hf_infiniband_TraceRecord_NodeID = -1;
968 static int hf_infiniband_TraceRecord_ChassisID = -1;
969 static int hf_infiniband_TraceRecord_EntryPortID = -1;
970 static int hf_infiniband_TraceRecord_ExitPortID = -1;
971 static int hf_infiniband_TraceRecord_EntryPort = -1;
972 static int hf_infiniband_TraceRecord_ExitPort = -1;
973
974 /* MultiPathRecord */
975 static int hf_infiniband_MultiPathRecord_RawTraffic = -1;
976 static int hf_infiniband_MultiPathRecord_FlowLabel = -1;
977 static int hf_infiniband_MultiPathRecord_HopLimit = -1;
978 static int hf_infiniband_MultiPathRecord_TClass = -1;
979 static int hf_infiniband_MultiPathRecord_Reversible = -1;
980 static int hf_infiniband_MultiPathRecord_NumbPath = -1;
981 static int hf_infiniband_MultiPathRecord_P_Key = -1;
982 static int hf_infiniband_MultiPathRecord_SL = -1;
983 static int hf_infiniband_MultiPathRecord_MTUSelector = -1;
984 static int hf_infiniband_MultiPathRecord_MTU = -1;
985 static int hf_infiniband_MultiPathRecord_RateSelector = -1;
986 static int hf_infiniband_MultiPathRecord_Rate = -1;
987 static int hf_infiniband_MultiPathRecord_PacketLifeTimeSelector = -1;
988 static int hf_infiniband_MultiPathRecord_PacketLifeTime = -1;
989 static int hf_infiniband_MultiPathRecord_IndependenceSelector = -1;
990 static int hf_infiniband_MultiPathRecord_GIDScope = -1;
991 static int hf_infiniband_MultiPathRecord_SGIDCount = -1;
992 static int hf_infiniband_MultiPathRecord_DGIDCount = -1;
993 static int hf_infiniband_MultiPathRecord_SDGID = -1;
994
995 /* Notice */
996 static int hf_infiniband_Notice_IsGeneric = -1;
997 static int hf_infiniband_Notice_Type = -1;
998 static int hf_infiniband_Notice_ProducerTypeVendorID = -1;
999 static int hf_infiniband_Notice_TrapNumberDeviceID = -1;
1000 static int hf_infiniband_Notice_IssuerLID = -1;
1001 static int hf_infiniband_Notice_NoticeToggle = -1;
1002 static int hf_infiniband_Notice_NoticeCount = -1;
1003 static int hf_infiniband_Notice_DataDetails = -1;
1004 /* static int hf_infiniband_Notice_IssuerGID = -1;             */
1005 /* static int hf_infiniband_Notice_ClassTrapSpecificData = -1; */
1006
1007 /* PortCounters attribute in Performance class */
1008 static int hf_infiniband_PortCounters = -1;
1009 static int hf_infiniband_PortCounters_PortSelect = -1;
1010 static int hf_infiniband_PortCounters_CounterSelect = -1;
1011 static int hf_infiniband_PortCounters_SymbolErrorCounter = -1;
1012 static int hf_infiniband_PortCounters_LinkErrorRecoveryCounter = -1;
1013 static int hf_infiniband_PortCounters_LinkDownedCounter = -1;
1014 static int hf_infiniband_PortCounters_PortRcvErrors = -1;
1015 static int hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors = -1;
1016 static int hf_infiniband_PortCounters_PortRcvSwitchRelayErrors = -1;
1017 static int hf_infiniband_PortCounters_PortXmitDiscards = -1;
1018 static int hf_infiniband_PortCounters_PortXmitConstraintErrors = -1;
1019 static int hf_infiniband_PortCounters_PortRcvConstraintErrors = -1;
1020 static int hf_infiniband_PortCounters_LocalLinkIntegrityErrors = -1;
1021 static int hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors = -1;
1022 static int hf_infiniband_PortCounters_VL15Dropped = -1;
1023 static int hf_infiniband_PortCounters_PortXmitData = -1;
1024 static int hf_infiniband_PortCounters_PortRcvData = -1;
1025 static int hf_infiniband_PortCounters_PortXmitPkts = -1;
1026 static int hf_infiniband_PortCounters_PortRcvPkts = -1;
1027
1028 /* Extended PortCounters attribute in Performance class */
1029 static int hf_infiniband_PortCountersExt = -1;
1030 static int hf_infiniband_PortCountersExt_PortSelect = -1;
1031 static int hf_infiniband_PortCountersExt_CounterSelect = -1;
1032 static int hf_infiniband_PortCountersExt_PortXmitData = -1;
1033 static int hf_infiniband_PortCountersExt_PortRcvData = -1;
1034 static int hf_infiniband_PortCountersExt_PortXmitPkts = -1;
1035 static int hf_infiniband_PortCountersExt_PortRcvPkts = -1;
1036 static int hf_infiniband_PortCountersExt_PortUnicastXmitPkts = -1;
1037 static int hf_infiniband_PortCountersExt_PortUnicastRcvPkts = -1;
1038 static int hf_infiniband_PortCountersExt_PortMulticastXmitPkts = -1;
1039 static int hf_infiniband_PortCountersExt_PortMulticastRcvPkts = -1;
1040
1041 /* Notice DataDetails and ClassTrapSpecific Data for certain traps
1042 * Note that traps reuse many fields, so they are only declared once under the first trap that they appear.
1043 * There is no need to redeclare them for specific Traps (as with other SA Attributes) because they are uniform between Traps. */
1044
1045 /* Parse DataDetails for a given Trap */
1046 static void parse_NoticeDataDetails(proto_tree*, tvbuff_t*, gint *offset, guint16 trapNumber);
1047
1048 /* Traps 64,65,66,67 */
1049 static int hf_infiniband_Trap_GIDADDR = -1;
1050
1051 /* Traps 68,69 */
1052 /* DataDetails */
1053 static int hf_infiniband_Trap_COMP_MASK = -1;
1054 static int hf_infiniband_Trap_WAIT_FOR_REPATH = -1;
1055 /* ClassTrapSpecificData */
1056 /* static int hf_infiniband_Trap_PATH_REC = -1;                              */
1057
1058 /* Trap 128 */
1059 static int hf_infiniband_Trap_LIDADDR = -1;
1060
1061 /* Trap 129, 130, 131 */
1062 static int hf_infiniband_Trap_PORTNO = -1;
1063
1064 /* Trap 144 */
1065 static int hf_infiniband_Trap_OtherLocalChanges = -1;
1066 static int hf_infiniband_Trap_CAPABILITYMASK = -1;
1067 static int hf_infiniband_Trap_LinkSpeecEnabledChange = -1;
1068 static int hf_infiniband_Trap_LinkWidthEnabledChange = -1;
1069 static int hf_infiniband_Trap_NodeDescriptionChange = -1;
1070
1071 /* Trap 145 */
1072 static int hf_infiniband_Trap_SYSTEMIMAGEGUID = -1;
1073
1074 /* Trap 256 */
1075 static int hf_infiniband_Trap_DRSLID = -1;
1076 static int hf_infiniband_Trap_METHOD = -1;
1077 static int hf_infiniband_Trap_ATTRIBUTEID = -1;
1078 static int hf_infiniband_Trap_ATTRIBUTEMODIFIER = -1;
1079 static int hf_infiniband_Trap_MKEY = -1;
1080 static int hf_infiniband_Trap_DRNotice = -1;
1081 static int hf_infiniband_Trap_DRPathTruncated = -1;
1082 static int hf_infiniband_Trap_DRHopCount = -1;
1083 static int hf_infiniband_Trap_DRNoticeReturnPath = -1;
1084
1085 /* Trap 257, 258 */
1086 static int hf_infiniband_Trap_LIDADDR1 = -1;
1087 static int hf_infiniband_Trap_LIDADDR2 = -1;
1088 static int hf_infiniband_Trap_KEY = -1;
1089 static int hf_infiniband_Trap_SL = -1;
1090 static int hf_infiniband_Trap_QP1 = -1;
1091 static int hf_infiniband_Trap_QP2 = -1;
1092 static int hf_infiniband_Trap_GIDADDR1 = -1;
1093 static int hf_infiniband_Trap_GIDADDR2 = -1;
1094
1095 /* Trap 259 */
1096 static int hf_infiniband_Trap_DataValid = -1;
1097 static int hf_infiniband_Trap_PKEY = -1;
1098 static int hf_infiniband_Trap_SWLIDADDR = -1;
1099
1100 /* Infiniband Link */
1101 static int hf_infiniband_link_op = -1;
1102 static int hf_infiniband_link_fctbs = -1;
1103 static int hf_infiniband_link_vl = -1;
1104 static int hf_infiniband_link_fccl = -1;
1105 static int hf_infiniband_link_lpcrc = -1;
1106
1107 /* Trap Type/Descriptions for dissection */
1108 static const value_string Operand_Description[]= {
1109     { 0, " Normal Flow Control"},
1110     { 1, " Flow Control Init"},
1111     { 0, NULL}
1112 };
1113
1114 /* Trap Type/Descriptions for dissection */
1115 static const value_string Trap_Description[]= {
1116     { 64, " (Informational) <GIDADDR> is now in service"},
1117     { 65, " (Informational) <GIDADDR> is out of service"},
1118     { 66, " (Informational) New Multicast Group with multicast address <GIDADDR> is now created"},
1119     { 67, " (Informational) Multicast Group with multicast address <GIDADDR> is now deleted"},
1120     { 68, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> are no longer valid"},
1121     { 69, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> have been recomputed"},
1122     { 128, " (Urgent) Link State of at least one port of switch at <LIDADDR> has changed"},
1123     { 129, " (Urgent) Local Link Integrity threshold reached at <LIDADDR><PORTNO>"},
1124     { 130, " (Urgent) Excessive Buffer OVerrun threshold reached at <LIDADDR><PORTNO>"},
1125     { 131, " (Urgent) Flow Control Update watchdog timer expired at <LIDADDR><PORTNO>"},
1126     { 144, " (Informational) CapMask, NodeDesc, LinkWidthEnabled or LinkSpeedEnabled at <LIDADDR> has been modified"},
1127     { 145, " (Informational) SystemImageGUID at <LIDADDR> has been modified.  New value is <SYSTEMIMAGEGUID>"},
1128     { 256, " (Security) Bad M_Key, <M_KEY> from <LIDADDR> attempted <METHOD> with <ATTRIBUTEID> and <ATTRIBUTEMODIFIER>"},
1129     { 257, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"},
1130     { 258, " (Security) Bad Q_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"},
1131     { 259, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL> at switch <LIDADDR><PORTNO>"},
1132     { 0, NULL}
1133 };
1134
1135
1136
1137
1138 /* MAD Management Classes
1139 * Classes from the Common MAD Header
1140 *
1141 *      Management Class Name        Class Description
1142 * ------------------------------------------------------------------------------------------------------------ */
1143 #define SUBN_LID_ROUTED 0x01        /* Subnet Management LID Route */
1144 #define SUBN_DIRECTED_ROUTE 0x81    /* Subnet Management Directed Route */
1145 #define SUBNADMN 0x03               /* Subnet Administration */
1146 #define PERF 0x04                   /* Performance Management */
1147 #define BM 0x05                     /* Baseboard Management (Tunneling of IB-ML commands through the IBA subnet) */
1148 #define DEV_MGT 0x06                /* Device Management */
1149 #define COM_MGT 0x07                /* Communications Management */
1150 #define SNMP 0x08                   /* SNMP Tunneling (tunneling of the SNMP protocol through the IBA fabric) */
1151 #define VENDOR_1_START 0x09         /* Start of first Vendor Specific Range */
1152 #define VENDOR_1_END 0x0F           /* End of first Vendor Specific Range */
1153 #define VENDOR_2_START 0x30         /* Start of second Vendor Specific Range */
1154 #define VENDOR_2_END 0x4F           /* End of the second Vendor Specific Range */
1155 #define APPLICATION_START 0x10      /* Start of Application Specific Range */
1156 #define APPLICATION_END 0x2F        /* End of Application Specific Range */
1157
1158 /* Performance class Attributes */
1159 #define ATTR_PORT_COUNTERS      0x0012
1160 #define ATTR_PORT_COUNTERS_EXT  0x001D
1161
1162 /* ComMgt class Attributes*/
1163 #define ATTR_CM_REQ             0x0010
1164 #define ATTR_CM_REP             0x0013
1165 #define ATTR_CM_RTU             0x0014
1166 #define ATTR_CM_REJ             0x0012
1167
1168 /* Link Next Header Values */
1169 #define IBA_GLOBAL 3
1170 #define IBA_LOCAL  2
1171 #define IP_NON_IBA 1
1172 #define RAW        0
1173
1174 /* OpCodeValues
1175 * Code Bits [7-5] Connection Type
1176 *           [4-0] Message Type
1177
1178 * Reliable Connection (RC)
1179 * [7-5] = 000 */
1180 #define RC_SEND_FIRST                   0 /*0x00000000 */
1181 #define RC_SEND_MIDDLE                  1 /*0x00000001 */
1182 #define RC_SEND_LAST                    2 /*0x00000010 */
1183 #define RC_SEND_LAST_IMM                3 /*0x00000011 */
1184 #define RC_SEND_ONLY                    4 /*0x00000100 */
1185 #define RC_SEND_ONLY_IMM                5 /*0x00000101 */
1186 #define RC_RDMA_WRITE_FIRST             6 /*0x00000110 */
1187 #define RC_RDMA_WRITE_MIDDLE            7 /*0x00000111 */
1188 #define RC_RDMA_WRITE_LAST              8 /*0x00001000 */
1189 #define RC_RDMA_WRITE_LAST_IMM          9 /*0x00001001 */
1190 #define RC_RDMA_WRITE_ONLY              10 /*0x00001010 */
1191 #define RC_RDMA_WRITE_ONLY_IMM          11 /*0x00001011 */
1192 #define RC_RDMA_READ_REQUEST            12 /*0x00001100 */
1193 #define RC_RDMA_READ_RESPONSE_FIRST     13 /*0x00001101 */
1194 #define RC_RDMA_READ_RESPONSE_MIDDLE    14 /*0x00001110 */
1195 #define RC_RDMA_READ_RESPONSE_LAST      15 /*0x00001111 */
1196 #define RC_RDMA_READ_RESPONSE_ONLY      16 /*0x00010000 */
1197 #define RC_ACKNOWLEDGE                  17 /*0x00010001 */
1198 #define RC_ATOMIC_ACKNOWLEDGE           18 /*0x00010010 */
1199 #define RC_CMP_SWAP                     19 /*0x00010011 */
1200 #define RC_FETCH_ADD                    20 /*0x00010100 */
1201 #define RC_SEND_LAST_INVAL              22 /*0x00010110 */
1202 #define RC_SEND_ONLY_INVAL              23 /*0x00010111 */
1203
1204 /* Reliable Datagram (RD)
1205 * [7-5] = 010 */
1206 #define RD_SEND_FIRST                   64 /*0x01000000 */
1207 #define RD_SEND_MIDDLE                  65 /*0x01000001 */
1208 #define RD_SEND_LAST                    66 /*0x01000010 */
1209 #define RD_SEND_LAST_IMM                67 /*0x01000011 */
1210 #define RD_SEND_ONLY                    68 /*0x01000100 */
1211 #define RD_SEND_ONLY_IMM                69 /*0x01000101 */
1212 #define RD_RDMA_WRITE_FIRST             70 /*0x01000110 */
1213 #define RD_RDMA_WRITE_MIDDLE            71 /*0x01000111 */
1214 #define RD_RDMA_WRITE_LAST              72 /*0x01001000 */
1215 #define RD_RDMA_WRITE_LAST_IMM          73 /*0x01001001 */
1216 #define RD_RDMA_WRITE_ONLY              74 /*0x01001010 */
1217 #define RD_RDMA_WRITE_ONLY_IMM          75 /*0x01001011 */
1218 #define RD_RDMA_READ_REQUEST            76 /*0x01001100 */
1219 #define RD_RDMA_READ_RESPONSE_FIRST     77 /*0x01001101 */
1220 #define RD_RDMA_READ_RESPONSE_MIDDLE    78 /*0x01001110 */
1221 #define RD_RDMA_READ_RESPONSE_LAST      79 /*0x01001111 */
1222 #define RD_RDMA_READ_RESPONSE_ONLY      80 /*0x01010000 */
1223 #define RD_ACKNOWLEDGE                  81 /*0x01010001 */
1224 #define RD_ATOMIC_ACKNOWLEDGE           82 /*0x01010010 */
1225 #define RD_CMP_SWAP                     83 /*0x01010011 */
1226 #define RD_FETCH_ADD                    84 /*0x01010100 */
1227 #define RD_RESYNC                       85 /*0x01010101 */
1228
1229 /* Unreliable Datagram (UD)
1230 * [7-5] = 011 */
1231 #define UD_SEND_ONLY                    100 /*0x01100100 */
1232 #define UD_SEND_ONLY_IMM                101 /*0x01100101 */
1233
1234 /* Unreliable Connection (UC)
1235 * [7-5] = 001 */
1236 #define UC_SEND_FIRST                   32 /*0x00100000 */
1237 #define UC_SEND_MIDDLE                  33 /*0x00100001 */
1238 #define UC_SEND_LAST                    34 /*0x00100010 */
1239 #define UC_SEND_LAST_IMM                35 /*0x00100011 */
1240 #define UC_SEND_ONLY                    36 /*0x00100100 */
1241 #define UC_SEND_ONLY_IMM                37 /*0x00100101 */
1242 #define UC_RDMA_WRITE_FIRST             38 /*0x00100110 */
1243 #define UC_RDMA_WRITE_MIDDLE            39 /*0x00100111 */
1244 #define UC_RDMA_WRITE_LAST              40 /*0x00101000 */
1245 #define UC_RDMA_WRITE_LAST_IMM          41 /*0x00101001 */
1246 #define UC_RDMA_WRITE_ONLY              42 /*0x00101010 */
1247 #define UC_RDMA_WRITE_ONLY_IMM          43 /*0x00101011 */
1248
1249 static const value_string OpCodeMap[] =
1250 {
1251     { RC_SEND_FIRST, "RC Send First " },
1252     { RC_SEND_MIDDLE, "RC Send Middle "},
1253     { RC_SEND_LAST, "RC Send Last " },
1254     { RC_SEND_LAST_IMM, "RC Send Last Immediate "},
1255     { RC_SEND_ONLY, "RC Send Only "},
1256     { RC_SEND_ONLY_IMM, "RC Send Only Immediate "},
1257     { RC_RDMA_WRITE_FIRST, "RC RDMA Write First " },
1258     { RC_RDMA_WRITE_MIDDLE, "RC RDMA Write Middle "},
1259     { RC_RDMA_WRITE_LAST, "RC RDMA Write Last "},
1260     { RC_RDMA_WRITE_LAST_IMM, "RC RDMA Write Last Immediate " },
1261     { RC_RDMA_WRITE_ONLY, "RC RDMA Write Only " },
1262     { RC_RDMA_WRITE_ONLY_IMM, "RC RDMA Write Only Immediate "},
1263     { RC_RDMA_READ_REQUEST,  "RC RDMA Read Request " },
1264     { RC_RDMA_READ_RESPONSE_FIRST, "RC RDMA Read Response First " },
1265     { RC_RDMA_READ_RESPONSE_MIDDLE, "RC RDMA Read Response Middle "},
1266     { RC_RDMA_READ_RESPONSE_LAST, "RC RDMA Read Response Last " },
1267     { RC_RDMA_READ_RESPONSE_ONLY, "RC RDMA Read Response Only "},
1268     { RC_ACKNOWLEDGE, "RC Acknowledge " },
1269     { RC_ATOMIC_ACKNOWLEDGE, "RC Atomic Acknowledge " },
1270     { RC_CMP_SWAP, "RC Compare Swap " },
1271     { RC_FETCH_ADD, "RC Fetch Add "},
1272     { RC_SEND_LAST_INVAL, "RC Send Last Invalidate "},
1273     { RC_SEND_ONLY_INVAL, "RC Send Only Invalidate " },
1274
1275
1276     { RD_SEND_FIRST, "RD Send First "},
1277     { RD_SEND_MIDDLE,"RD Send Middle " },
1278     { RD_SEND_LAST, "RD Send Last "},
1279     { RD_SEND_LAST_IMM, "RD Last Immediate " },
1280     { RD_SEND_ONLY,"RD Send Only "},
1281     { RD_SEND_ONLY_IMM,"RD Send Only Immediate "},
1282     { RD_RDMA_WRITE_FIRST,"RD RDMA Write First "},
1283     { RD_RDMA_WRITE_MIDDLE, "RD RDMA Write Middle "},
1284     { RD_RDMA_WRITE_LAST,"RD RDMA Write Last "},
1285     { RD_RDMA_WRITE_LAST_IMM,"RD RDMA Write Last Immediate "},
1286     { RD_RDMA_WRITE_ONLY,"RD RDMA Write Only "},
1287     { RD_RDMA_WRITE_ONLY_IMM,"RD RDMA Write Only Immediate "},
1288     { RD_RDMA_READ_REQUEST,"RD RDMA Read Request "},
1289     { RD_RDMA_READ_RESPONSE_FIRST,"RD RDMA Read Response First "},
1290     { RD_RDMA_READ_RESPONSE_MIDDLE,"RD RDMA Read Response Middle "},
1291     { RD_RDMA_READ_RESPONSE_LAST,"RD RDMA Read Response Last "},
1292     { RD_RDMA_READ_RESPONSE_ONLY,"RD RDMA Read Response Only "},
1293     { RD_ACKNOWLEDGE,"RD Acknowledge "},
1294     { RD_ATOMIC_ACKNOWLEDGE,"RD Atomic Acknowledge "},
1295     { RD_CMP_SWAP,"RD Compare Swap "},
1296     { RD_FETCH_ADD, "RD Fetch Add "},
1297     { RD_RESYNC,"RD RESYNC "},
1298
1299
1300     { UD_SEND_ONLY, "UD Send Only "},
1301     { UD_SEND_ONLY_IMM, "UD Send Only Immediate "},
1302
1303
1304     { UC_SEND_FIRST,"UC Send First "},
1305     { UC_SEND_MIDDLE,"UC Send Middle "},
1306     { UC_SEND_LAST,"UC Send Last "},
1307     { UC_SEND_LAST_IMM,"UC Send Last Immediate "},
1308     { UC_SEND_ONLY,"UC Send Only "},
1309     { UC_SEND_ONLY_IMM,"UC Send Only Immediate "},
1310     { UC_RDMA_WRITE_FIRST,"UC RDMA Write First"},
1311     { UC_RDMA_WRITE_MIDDLE,"Unreliable Connection RDMA Write Middle "},
1312     { UC_RDMA_WRITE_LAST,"UC RDMA Write Last "},
1313     { UC_RDMA_WRITE_LAST_IMM,"UC RDMA Write Last Immediate "},
1314     { UC_RDMA_WRITE_ONLY,"UC RDMA Write Only "},
1315     { UC_RDMA_WRITE_ONLY_IMM,"UC RDMA Write Only Immediate "},
1316     { 0, NULL}
1317
1318 };
1319
1320
1321
1322 /* Header Ordering Based on OPCODES
1323 * These are simply an enumeration of the possible header combinations defined by the IB Spec.
1324 * These enumerations
1325 * #DEFINE [HEADER_ORDER]         [ENUM]
1326 * __________________________________ */
1327 #define RDETH_DETH_PAYLD            0
1328 /* __________________________________ */
1329 #define RDETH_DETH_RETH_PAYLD       1
1330 /* __________________________________ */
1331 #define RDETH_DETH_IMMDT_PAYLD      2
1332 /* __________________________________ */
1333 #define RDETH_DETH_RETH_IMMDT_PAYLD 3
1334 /* __________________________________ */
1335 #define RDETH_DETH_RETH             4
1336 /* __________________________________ */
1337 #define RDETH_AETH_PAYLD            5
1338 /* __________________________________ */
1339 #define RDETH_PAYLD                 6
1340 /* __________________________________ */
1341 #define RDETH_AETH                  7
1342 /* __________________________________ */
1343 #define RDETH_AETH_ATOMICACKETH     8
1344 /* __________________________________ */
1345 #define RDETH_DETH_ATOMICETH        9
1346 /* ___________________________________ */
1347 #define RDETH_DETH                  10
1348 /* ___________________________________ */
1349 #define DETH_PAYLD                  11
1350 /* ___________________________________ */
1351 #define DETH_IMMDT_PAYLD            12
1352 /* ___________________________________ */
1353 #define PAYLD                       13
1354 /* ___________________________________ */
1355 #define IMMDT_PAYLD                 14
1356 /* ___________________________________ */
1357 #define RETH_PAYLD                  15
1358 /* ___________________________________ */
1359 #define RETH_IMMDT_PAYLD            16
1360 /* ___________________________________ */
1361 #define RETH                        17
1362 /* ___________________________________ */
1363 #define AETH_PAYLD                  18
1364 /* ___________________________________ */
1365 #define AETH                        19
1366 /* ___________________________________ */
1367 #define AETH_ATOMICACKETH           20
1368 /* ___________________________________ */
1369 #define ATOMICETH                   21
1370 /* ___________________________________ */
1371 #define IETH_PAYLD                  22
1372 /* ___________________________________ */
1373
1374
1375 /* Infiniband transport services
1376    These are an enumeration of the transport services over which an IB packet
1377    might be sent. The values match the corresponding 3 bits of the opCode field
1378    in the BTH  */
1379 #define TRANSPORT_RC    0
1380 #define TRANSPORT_UC    1
1381 #define TRANSPORT_RD    2
1382 #define TRANSPORT_UD    3
1383
1384
1385 /* Array of all availavle OpCodes to make matching a bit easier.
1386 * The OpCodes dictate the header sequence following in the packet.
1387 * These arrays tell the dissector which headers must be decoded for the given OpCode. */
1388 static guint32 opCode_RDETH_DETH_ATOMICETH[] = {
1389  RD_CMP_SWAP,
1390  RD_FETCH_ADD
1391 };
1392 static guint32 opCode_IETH_PAYLD[] = {
1393  RC_SEND_LAST_INVAL,
1394  RC_SEND_ONLY_INVAL
1395 };
1396 static guint32 opCode_ATOMICETH[] = {
1397  RC_CMP_SWAP,
1398  RC_FETCH_ADD
1399 };
1400 static guint32 opCode_RDETH_DETH_RETH_PAYLD[] = {
1401  RD_RDMA_WRITE_FIRST,
1402  RD_RDMA_WRITE_ONLY
1403 };
1404 static guint32 opCode_RETH_IMMDT_PAYLD[] = {
1405  RC_RDMA_WRITE_ONLY_IMM,
1406  UC_RDMA_WRITE_ONLY_IMM
1407 };
1408 static guint32 opCode_RDETH_DETH_IMMDT_PAYLD[] = {
1409  RD_SEND_LAST_IMM,
1410  RD_SEND_ONLY_IMM,
1411  RD_RDMA_WRITE_LAST_IMM
1412 };
1413
1414 static guint32 opCode_RDETH_AETH_PAYLD[] = {
1415  RD_RDMA_READ_RESPONSE_FIRST,
1416  RD_RDMA_READ_RESPONSE_LAST,
1417  RD_RDMA_READ_RESPONSE_ONLY
1418 };
1419 static guint32 opCode_AETH_PAYLD[] = {
1420  RC_RDMA_READ_RESPONSE_FIRST,
1421  RC_RDMA_READ_RESPONSE_LAST,
1422  RC_RDMA_READ_RESPONSE_ONLY
1423 };
1424 static guint32 opCode_RETH_PAYLD[] = {
1425  RC_RDMA_WRITE_FIRST,
1426  RC_RDMA_WRITE_ONLY,
1427  UC_RDMA_WRITE_FIRST,
1428  UC_RDMA_WRITE_ONLY
1429 };
1430
1431 static guint32 opCode_RDETH_DETH_PAYLD[] = {
1432  RD_SEND_FIRST,
1433  RD_SEND_MIDDLE,
1434  RD_SEND_LAST,
1435  RD_SEND_ONLY,
1436  RD_RDMA_WRITE_MIDDLE,
1437  RD_RDMA_WRITE_LAST
1438 };
1439
1440 static guint32 opCode_IMMDT_PAYLD[] = {
1441  RC_SEND_LAST_IMM,
1442  RC_SEND_ONLY_IMM,
1443  RC_RDMA_WRITE_LAST_IMM,
1444  UC_SEND_LAST_IMM,
1445  UC_SEND_ONLY_IMM,
1446  UC_RDMA_WRITE_LAST_IMM
1447 };
1448
1449 static guint32 opCode_PAYLD[] = {
1450  RC_SEND_FIRST,
1451  RC_SEND_MIDDLE,
1452  RC_SEND_LAST,
1453  RC_SEND_ONLY,
1454  RC_RDMA_WRITE_MIDDLE,
1455  RC_RDMA_WRITE_LAST,
1456  RC_RDMA_READ_RESPONSE_MIDDLE,
1457  UC_SEND_FIRST,
1458  UC_SEND_MIDDLE,
1459  UC_SEND_LAST,
1460  UC_SEND_ONLY,
1461  UC_RDMA_WRITE_MIDDLE,
1462  UC_RDMA_WRITE_LAST
1463 };
1464
1465 /* It is not necessary to create arrays for these OpCodes since they indicate only one further header.
1466 *  We can just decode it directly
1467
1468 * static guint32 opCode_DETH_IMMDT_PAYLD[] = {
1469 * UD_SEND_ONLY_IMM
1470 * };
1471 * static guint32 opCode_DETH_PAYLD[] = {
1472 * UD_SEND_ONLY
1473 * };
1474 * static guint32 opCode_RDETH_DETH[] = {
1475 * RD_RESYNC
1476 * };
1477 * static guint32 opCode_RDETH_DETH_RETH[] = {
1478 * RD_RDMA_READ_REQUEST
1479 * };
1480 * static guint32 opCode_RDETH_DETH_RETH_IMMDT_PAYLD[] = {
1481 * RD_RDMA_WRITE_ONLY_IMM
1482 * };
1483 * static guint32 opCode_RDETH_AETH_ATOMICACKETH[] = {
1484 * RD_ATOMIC_ACKNOWLEDGE
1485 * };
1486 * static guint32 opCode_RDETH_AETH[] = {
1487 * RD_ACKNOWLEDGE
1488 * };
1489 * static guint32 opCode_RDETH_PAYLD[] = {
1490 * RD_RDMA_READ_RESPONSE_MIDDLE
1491 * };
1492 * static guint32 opCode_AETH_ATOMICACKETH[] = {
1493 * RC_ATOMIC_ACKNOWLEDGE
1494 * };
1495 * static guint32 opCode_RETH[] = {
1496 * RC_RDMA_READ_REQUEST
1497 * };
1498 * static guint32 opCode_AETH[] = {
1499 * RC_ACKNOWLEDGE
1500 * }; */
1501
1502 static void *src_addr = NULL,     /* the address to be displayed in the source/destination columns */
1503             *dst_addr = NULL;     /* (lid/gid number) will be stored here */
1504
1505 #define ADDR_MAX_LEN  sizeof("IPv6 over IB Packet")      /* maximum length of src_addr and dst_addr is for IPoIB
1506                                                             where we print an explanation string */
1507
1508 static gint8 transport_type = -1;      /* reflects the transport type of the packet being parsed.
1509                                           only use one of the TRANSPORT_* values for this field */
1510
1511 /* settings to be set by the user via the preferences dialog */
1512 static gboolean pref_dissect_eoib = TRUE;
1513 static gboolean pref_identify_iba_payload = TRUE;
1514
1515 /* saves information about connections that have been/are in the process of being
1516    negotiated via ConnectionManagement packets */
1517 typedef struct {
1518     guint8 req_gid[GID_SIZE],
1519            resp_gid[GID_SIZE];  /* GID of requester/responder, respectively */
1520     guint16 req_lid,
1521             resp_lid;   /* LID of requester/responder, respectively */
1522     guint32 req_qp,
1523             resp_qp;            /* QP number of requester/responder, respectively */
1524     guint64 service_id;         /* service id for this connection */
1525 } connection_context;
1526
1527 /* holds a table of connection contexts being negotiated by CM. the key is a obtained
1528    using ADD_ADDRESS_TO_HASH(initiator address, TransactionID) [remember that the 1st
1529    argument to ADD_ADDRESS_TO_HASH must be an lvalue. */
1530 static GHashTable *CM_context_table = NULL;
1531
1532 /* heuristics sub-dissectors list for dissecting the data payload of IB packets */
1533 static heur_dissector_list_t heur_dissectors_payload;
1534 /* heuristics sub-dissectors list for dissecting the PrivateData of CM packets */
1535 static heur_dissector_list_t heur_dissectors_cm_private;
1536
1537 /* ----- This sections contains various utility functions indirectly related to Infiniband dissection ---- */
1538
1539 /* g_int64_hash, g_int64_equal are defined starting glib 2.22 - otherwise, we'll have to
1540    provide them ourselves! */
1541 #if !GLIB_CHECK_VERSION(2,22,0)
1542 guint
1543 g_int64_hash (gconstpointer v)
1544 {
1545   return (guint) *(const gint64*) v;
1546 }
1547
1548 gboolean
1549 g_int64_equal (gconstpointer v1,
1550                gconstpointer v2)
1551 {
1552   return *((const gint64*) v1) == *((const gint64*) v2);
1553 }
1554 #endif
1555
1556 void table_destroy_notify(gpointer data) {
1557     g_free(data);
1558 }
1559
1560 /* --------------------------------------------------------------------------------------------------------*/
1561
1562 /* Helper dissector for correctly dissecting RoCE packets (encapsulated within an Ethernet */
1563 /* frame). The only difference from regular IB packets is that RoCE packets do not contain */
1564 /* a LRH, and always start with a GRH.                                                      */
1565 static void
1566 dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1567 {
1568     /* this is a RoCE packet, so signal the IB dissector not to look for LRH */
1569     dissect_infiniband_common(tvb, pinfo, tree, TRUE);
1570 }
1571
1572 static void
1573 dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1574 {
1575     dissect_infiniband_common(tvb, pinfo, tree, FALSE);
1576 }
1577
1578 /* Common Dissector for both InfiniBand and RoCE packets
1579  * IN:
1580  *       tvb - The tvbbuff of packet data
1581  *       pinfo - The packet info structure with column information
1582  *       tree - The tree structure under which field nodes are to be added
1583  *       starts_with_grh - If true this packets start with a GRH header (RoCE), otherwise with LRH as usual
1584  * Notes:
1585  * 1.) Floating "offset+=" statements should probably be "functionized" but they are inline
1586  * Offset is only passed by reference in specific places, so do not be confused when following code
1587  * In any code path, adding up "offset+=" statements will tell you what byte you are at */
1588 static void
1589 dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh)
1590 {
1591     /* Top Level Item */
1592     proto_item *infiniband_packet = NULL;
1593
1594     /* The Headers Subtree */
1595     proto_tree *all_headers_tree = NULL;
1596
1597     /* LRH - Local Route Header */
1598     proto_tree *local_route_header_tree = NULL;
1599     proto_item *local_route_header_item = NULL;
1600
1601     /* GRH - Global Route Header */
1602     proto_tree *global_route_header_tree = NULL;
1603     proto_item *global_route_header_item = NULL;
1604
1605     /* BTH - Base Transport header */
1606     proto_tree *base_transport_header_tree = NULL;
1607     proto_item *base_transport_header_item = NULL;
1608
1609     /* Raw Data */
1610     proto_item *RAWDATA_header_item;
1611     guint8 lnh_val = 0;             /* Link Next Header Value */
1612     gint offset = 0;                /* Current Offset */
1613
1614     /* General Variables */
1615     gboolean bthFollows = FALSE;    /* Tracks if we are parsing a BTH.  This is a significant decision point */
1616     guint8 virtualLane = 0;         /* IB VirtualLane.  Keyed off of for detecting subnet admin/management */
1617     guint8 opCode = 0;              /* OpCode from BTH header. */
1618     gint32 nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */
1619     guint8 nxtHdr = 0;              /* Keyed off for header dissection order */
1620     guint16 packetLength = 0;       /* Packet Length.  We track this as tvb_length - offset.   */
1621                                     /*  It provides the parsing methods a known size            */
1622                                     /*   that must be available for that header.                */
1623     struct e_in6_addr SRCgid;       /* Structures to hold GIDs should we need them */
1624     struct e_in6_addr DSTgid;
1625     gint crc_length = 0;
1626
1627     /* allocate space for source/destination addresses if not allocated already. we will fill them in later */
1628     if (!src_addr)
1629         src_addr = ep_alloc(ADDR_MAX_LEN);
1630
1631     if (!dst_addr)
1632         dst_addr = ep_alloc(ADDR_MAX_LEN);
1633
1634     pinfo->srcport = pinfo->destport = 0xffffffff;  /* set the src/dest QPN to something impossible instead of the default 0,
1635                                                        so we don't mistake it for a MAD. (QP is only 24bit, so can't be 0xffffffff)*/
1636
1637     /* add any code that should only run the first time the packet is dissected here: */
1638     if (!pinfo->fd->flags.visited)
1639     {
1640         pinfo->ptype = PT_IBQP;     /* set the port-type for this packet to be Infiniband QP number */
1641     }
1642
1643     /* Mark the Packet type as Infiniband in the wireshark UI */
1644     /* Clear other columns */
1645     col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand");
1646     col_clear(pinfo->cinfo, COL_INFO);
1647
1648     /* Get the parent tree from the ERF dissector.  We don't want to nest under ERF */
1649     if(tree && tree->parent)
1650     {
1651         /* Set the normal tree outside of ERF */
1652         tree = tree->parent;
1653         /* Set a global reference for nested protocols */
1654         top_tree = tree;
1655     }
1656
1657     /* The "quick-dissection" code in dissect_general_info skips lots of the recently-added code
1658        for saving context etc. It is no longer viable to maintain two code branches, so we have
1659        (temporarily?) disabled the second one. All dissection now goes through the full branch,
1660        using a NULL tree pointer if this is not a full dissection call. Take care not to dereference
1661        the tree pointer or any subtree pointers you create using it and you'll be fine. */
1662     if(0 && !tree)
1663     {
1664         /* If no packet details are being dissected, extract some high level info for the packet view */
1665         /* Assigns column values rather than full tree population */
1666         dissect_general_info(tvb, offset, pinfo, starts_with_grh);
1667         return;
1668     }
1669
1670     /* Top Level Packet */
1671     infiniband_packet = proto_tree_add_item(tree, proto_infiniband, tvb, offset, -1, ENC_NA);
1672
1673     /* Headers Level Tree */
1674     all_headers_tree = proto_item_add_subtree(infiniband_packet, ett_all_headers);
1675
1676     if (starts_with_grh) {
1677         /* this is a RoCE packet, skip LRH parsing */
1678         lnh_val = IBA_GLOBAL;
1679         packetLength = tvb_get_ntohs(tvb, 4);   /* since we have no LRH to get PktLen from, use that of the GRH */
1680         goto skip_lrh;
1681     }
1682
1683     /* Local Route Header Subtree */
1684     local_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_LRH, tvb, offset, 8, ENC_NA);
1685     proto_item_set_text(local_route_header_item, "%s", "Local Route Header");
1686     local_route_header_tree = proto_item_add_subtree(local_route_header_item, ett_lrh);
1687
1688     proto_tree_add_item(local_route_header_tree, hf_infiniband_virtual_lane,            tvb, offset, 1, ENC_BIG_ENDIAN);
1689
1690
1691     /* Get the Virtual Lane.  We'll use this to identify Subnet Management and Subnet Administration Packets. */
1692     virtualLane =  tvb_get_guint8(tvb, offset);
1693     virtualLane = virtualLane & 0xF0;
1694
1695
1696     proto_tree_add_item(local_route_header_tree, hf_infiniband_link_version,            tvb, offset, 1, ENC_BIG_ENDIAN); offset+=1;
1697     proto_tree_add_item(local_route_header_tree, hf_infiniband_service_level,           tvb, offset, 1, ENC_BIG_ENDIAN);
1698
1699     proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved2,               tvb, offset, 1, ENC_BIG_ENDIAN);
1700     proto_tree_add_item(local_route_header_tree, hf_infiniband_link_next_header,        tvb, offset, 1, ENC_BIG_ENDIAN);
1701
1702
1703     /* Save Link Next Header... This tells us what the next header is. */
1704     lnh_val =  tvb_get_guint8(tvb, offset);
1705     lnh_val = lnh_val & 0x03;
1706     offset+=1;
1707
1708
1709     proto_tree_add_item(local_route_header_tree, hf_infiniband_destination_local_id,    tvb, offset, 2, ENC_BIG_ENDIAN);
1710
1711
1712     /* Set destination in packet view. */
1713     *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset);
1714     SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr);
1715
1716     offset+=2;
1717
1718     proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved5,               tvb, offset, 2, ENC_BIG_ENDIAN);
1719
1720     packetLength = tvb_get_ntohs(tvb, offset); /* Get the Packet Length. This will determine payload size later on. */
1721     packetLength = packetLength & 0x07FF;      /* Mask off top 5 bits, they are reserved */
1722     packetLength = packetLength * 4;           /* Multiply by 4 to get true byte length. This is by specification.  */
1723                                                /*   PktLen is size in 4 byte words (byteSize /4). */
1724
1725     proto_tree_add_item(local_route_header_tree, hf_infiniband_packet_length,           tvb, offset, 2, ENC_BIG_ENDIAN); offset+=2;
1726     proto_tree_add_item(local_route_header_tree, hf_infiniband_source_local_id,         tvb, offset, 2, ENC_BIG_ENDIAN);
1727
1728     /* Set Source in packet view. */
1729     *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset);
1730     SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr);
1731
1732     offset+=2;
1733     packetLength -= 8; /* Shave 8 bytes for the LRH. */
1734
1735 skip_lrh:
1736
1737     /* Key off Link Next Header.  This tells us what High Level Data Format we have */
1738     switch(lnh_val)
1739     {
1740         case IBA_GLOBAL:
1741             global_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_GRH, tvb, offset, 40, ENC_NA);
1742             proto_item_set_text(global_route_header_item, "%s", "Global Route Header");
1743             global_route_header_tree = proto_item_add_subtree(global_route_header_item, ett_grh);
1744
1745             proto_tree_add_item(global_route_header_tree, hf_infiniband_ip_version,         tvb, offset, 1, ENC_BIG_ENDIAN);
1746             proto_tree_add_item(global_route_header_tree, hf_infiniband_traffic_class,      tvb, offset, 2, ENC_BIG_ENDIAN);
1747             proto_tree_add_item(global_route_header_tree, hf_infiniband_flow_label,         tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;
1748
1749             proto_tree_add_item(global_route_header_tree, hf_infiniband_payload_length,     tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1750
1751             nxtHdr = tvb_get_guint8(tvb, offset);
1752
1753             proto_tree_add_item(global_route_header_tree, hf_infiniband_next_header,        tvb, offset, 1, ENC_BIG_ENDIAN); offset +=1;
1754             proto_tree_add_item(global_route_header_tree, hf_infiniband_hop_limit,          tvb, offset, 1, ENC_BIG_ENDIAN); offset +=1;
1755             proto_tree_add_item(global_route_header_tree, hf_infiniband_source_gid,         tvb, offset, 16, ENC_NA);
1756
1757             tvb_get_ipv6(tvb, offset, &SRCgid);
1758
1759             /* set source GID in packet view*/
1760             memcpy(src_addr, &SRCgid, GID_SIZE);
1761             SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr);
1762
1763             offset += 16;
1764
1765             proto_tree_add_item(global_route_header_tree, hf_infiniband_destination_gid,    tvb, offset, 16, ENC_NA);
1766
1767             tvb_get_ipv6(tvb, offset, &DSTgid);
1768
1769             /* set destination GID in packet view*/
1770             memcpy(dst_addr, &DSTgid, GID_SIZE);
1771             SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr);
1772
1773             offset += 16;
1774             packetLength -= 40; /* Shave 40 bytes for GRH */
1775
1776             if(nxtHdr != 0x1B)
1777             {
1778                 /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */
1779                 break;
1780             }
1781             /* otherwise fall through and start parsing BTH */
1782         case IBA_LOCAL:
1783             bthFollows = TRUE;
1784             base_transport_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_BTH, tvb, offset, 12, ENC_NA);
1785             proto_item_set_text(base_transport_header_item, "%s", "Base Transport Header");
1786             base_transport_header_tree = proto_item_add_subtree(base_transport_header_item, ett_bth);
1787             proto_tree_add_item(base_transport_header_tree, hf_infiniband_opcode,                       tvb, offset, 1, ENC_BIG_ENDIAN);
1788
1789             /* Get the OpCode - this tells us what headers are following */
1790             opCode = tvb_get_guint8(tvb, offset);
1791             col_append_str(pinfo->cinfo, COL_INFO, val_to_str((guint32)opCode, OpCodeMap, "Unknown OpCode"));
1792             offset +=1;
1793
1794             proto_tree_add_item(base_transport_header_tree, hf_infiniband_solicited_event,              tvb, offset, 1, ENC_BIG_ENDIAN);
1795             proto_tree_add_item(base_transport_header_tree, hf_infiniband_migreq,                       tvb, offset, 1, ENC_BIG_ENDIAN);
1796             proto_tree_add_item(base_transport_header_tree, hf_infiniband_pad_count,                    tvb, offset, 1, ENC_BIG_ENDIAN);
1797             proto_tree_add_item(base_transport_header_tree, hf_infiniband_transport_header_version,     tvb, offset, 1, ENC_BIG_ENDIAN); offset +=1;
1798             proto_tree_add_item(base_transport_header_tree, hf_infiniband_partition_key,                tvb, offset, 2, ENC_BIG_ENDIAN); offset +=2;
1799             proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved8,                    tvb, offset, 1, ENC_BIG_ENDIAN); offset +=1;
1800             proto_tree_add_item(base_transport_header_tree, hf_infiniband_destination_qp,               tvb, offset, 3, ENC_BIG_ENDIAN);
1801             pinfo->destport = tvb_get_ntoh24(tvb, offset); offset +=3;
1802             proto_tree_add_item(base_transport_header_tree, hf_infiniband_acknowledge_request,          tvb, offset, 1, ENC_BIG_ENDIAN);
1803             proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved7,                    tvb, offset, 1, ENC_BIG_ENDIAN); offset +=1;
1804             proto_tree_add_item(base_transport_header_tree, hf_infiniband_packet_sequence_number,       tvb, offset, 3, ENC_BIG_ENDIAN); offset +=3;
1805
1806
1807             packetLength -= 12; /* Shave 12 for Base Transport Header */
1808
1809         break;
1810         case IP_NON_IBA:
1811             /* Raw IPv6 Packet */
1812             g_snprintf(dst_addr,  ADDR_MAX_LEN, "IPv6 over IB Packet");
1813             SET_ADDRESS(&pinfo->dst,  AT_STRINGZ, (int)strlen(dst_addr)+1, dst_addr);
1814
1815             parse_IPvSix(all_headers_tree, tvb, &offset, pinfo);
1816             break;
1817         case RAW:
1818             parse_RWH(all_headers_tree, tvb, &offset, pinfo);
1819             break;
1820         default:
1821             /* Unknown Packet */
1822             RAWDATA_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_raw_data, tvb, offset, -1, ENC_NA);
1823             proto_item_set_text(RAWDATA_header_item, "%s", "Unknown Raw Data - IB Encapsulated");
1824             break;
1825     }
1826
1827     /* Base Transport header is hit quite often, however it is alone since it is the exception not the rule */
1828     /* Only IBA Local packets use it */
1829     if(bthFollows)
1830     {
1831         /* Find our next header sequence based on the Opcode
1832         * Each case decrements the packetLength by the amount of bytes consumed by each header.
1833         * The find_next_header_sequence method could be used to automate this.
1834         * We need to keep track of this so we know much data to mark as payload/ICRC/VCRC values. */
1835
1836         transport_type = (opCode & 0xE0) >> 5;   /* save transport type for identifying EoIB payloads later... */
1837         nextHeaderSequence = find_next_header_sequence((guint32) opCode);
1838
1839         /* find_next_header_sequence gives us the DEFINE value corresponding to the header order following */
1840         /* Enumerations are named intuitively, e.g. RDETH DETH PAYLOAD means there is an RDETH Header, DETH Header, and a packet payload */
1841         switch(nextHeaderSequence)
1842         {
1843             case RDETH_DETH_PAYLD:
1844                 parse_RDETH(all_headers_tree, tvb, &offset);
1845                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1846
1847                 packetLength -= 4; /* RDETH */
1848                 packetLength -= 8; /* DETH */
1849
1850                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1851                 break;
1852             case RDETH_DETH_RETH_PAYLD:
1853                 parse_RDETH(all_headers_tree, tvb, &offset);
1854                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1855                 parse_RETH(all_headers_tree, tvb, &offset);
1856
1857                 packetLength -= 4; /* RDETH */
1858                 packetLength -= 8; /* DETH */
1859                 packetLength -= 16; /* RETH */
1860
1861                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1862                 break;
1863             case RDETH_DETH_IMMDT_PAYLD:
1864                 parse_RDETH(all_headers_tree, tvb, &offset);
1865                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1866                 parse_IMMDT(all_headers_tree, tvb, &offset);
1867
1868                 packetLength -= 4; /* RDETH */
1869                 packetLength -= 8; /* DETH */
1870                 packetLength -= 4; /* IMMDT */
1871
1872                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1873                 break;
1874             case RDETH_DETH_RETH_IMMDT_PAYLD:
1875                 parse_RDETH(all_headers_tree, tvb, &offset);
1876                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1877                 parse_RETH(all_headers_tree, tvb, &offset);
1878                 parse_IMMDT(all_headers_tree, tvb, &offset);
1879
1880                 packetLength -= 4; /* RDETH */
1881                 packetLength -= 8; /* DETH */
1882                 packetLength -= 16; /* RETH */
1883                 packetLength -= 4; /* IMMDT */
1884
1885                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1886                 break;
1887             case RDETH_DETH_RETH:
1888                 parse_RDETH(all_headers_tree, tvb, &offset);
1889                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1890                 parse_RETH(all_headers_tree, tvb, &offset);
1891
1892                 packetLength -= 4; /* RDETH */
1893                 packetLength -= 8; /* DETH */
1894                 packetLength -= 16; /* RETH */
1895
1896                 break;
1897             case RDETH_AETH_PAYLD:
1898                 parse_RDETH(all_headers_tree, tvb, &offset);
1899                 parse_AETH(all_headers_tree, tvb, &offset);
1900
1901                 packetLength -= 4; /* RDETH */
1902                 packetLength -= 4; /* AETH */
1903
1904                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1905                 break;
1906             case RDETH_PAYLD:
1907                 parse_RDETH(all_headers_tree, tvb, &offset);
1908
1909                 packetLength -= 4; /* RDETH */
1910
1911                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1912                 break;
1913             case RDETH_AETH:
1914                 parse_AETH(all_headers_tree, tvb, &offset);
1915
1916                 packetLength -= 4; /* RDETH */
1917                 packetLength -= 4; /* AETH */
1918
1919
1920                 break;
1921             case RDETH_AETH_ATOMICACKETH:
1922                 parse_RDETH(all_headers_tree, tvb, &offset);
1923                 parse_AETH(all_headers_tree, tvb, &offset);
1924                 parse_ATOMICACKETH(all_headers_tree, tvb, &offset);
1925
1926                 packetLength -= 4; /* RDETH */
1927                 packetLength -= 4; /* AETH */
1928                 packetLength -= 8; /* AtomicAckETH */
1929
1930
1931                 break;
1932             case RDETH_DETH_ATOMICETH:
1933                 parse_RDETH(all_headers_tree, tvb, &offset);
1934                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1935                 parse_ATOMICETH(all_headers_tree, tvb, &offset);
1936
1937                 packetLength -= 4; /* RDETH */
1938                 packetLength -= 8; /* DETH */
1939                 packetLength -= 28; /* AtomicETH */
1940
1941                 break;
1942             case RDETH_DETH:
1943                 parse_RDETH(all_headers_tree, tvb, &offset);
1944                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1945
1946                 packetLength -= 4; /* RDETH */
1947                 packetLength -= 8; /* DETH */
1948
1949                 break;
1950             case DETH_PAYLD:
1951                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1952
1953                 packetLength -= 8; /* DETH */
1954
1955                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1956                 break;
1957             case PAYLD:
1958
1959                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1960                 break;
1961             case IMMDT_PAYLD:
1962                 parse_IMMDT(all_headers_tree, tvb, &offset);
1963
1964                 packetLength -= 4; /* IMMDT */
1965
1966                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1967                 break;
1968             case RETH_PAYLD:
1969                 parse_RETH(all_headers_tree, tvb, &offset);
1970
1971                 packetLength -= 16; /* RETH */
1972
1973                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1974                 break;
1975             case RETH:
1976                 parse_RETH(all_headers_tree, tvb, &offset);
1977
1978                 packetLength -= 16; /* RETH */
1979
1980                 break;
1981             case AETH_PAYLD:
1982                 parse_AETH(all_headers_tree, tvb, &offset);
1983
1984                 packetLength -= 4; /* AETH */
1985
1986                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
1987                 break;
1988             case AETH:
1989                 parse_AETH(all_headers_tree, tvb, &offset);
1990
1991                 packetLength -= 4; /* AETH */
1992
1993                 break;
1994             case AETH_ATOMICACKETH:
1995                 parse_AETH(all_headers_tree, tvb, &offset);
1996                 parse_ATOMICACKETH(all_headers_tree, tvb, &offset);
1997
1998                 packetLength -= 4; /* AETH */
1999                 packetLength -= 8; /* AtomicAckETH */
2000
2001                 break;
2002             case ATOMICETH:
2003                 parse_ATOMICETH(all_headers_tree, tvb, &offset);
2004
2005                 packetLength -= 28; /* AtomicETH */
2006
2007                 break;
2008             case IETH_PAYLD:
2009                 parse_IETH(all_headers_tree, tvb, &offset);
2010
2011                 packetLength -= 4; /* IETH */
2012
2013                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
2014                 break;
2015             case DETH_IMMDT_PAYLD:
2016                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
2017                 parse_IMMDT(all_headers_tree, tvb, &offset);
2018
2019                 packetLength -= 8; /* DETH */
2020                 packetLength -= 4; /* IMMDT */
2021
2022                 parse_PAYLOAD(all_headers_tree, pinfo, tvb, &offset, packetLength);
2023                 break;
2024             default:
2025                 parse_VENDOR(all_headers_tree, tvb, &offset);
2026                 break;
2027
2028         }
2029
2030     }
2031     /* Display the ICRC/VCRC */
2032     /* Doing it this way rather than in a variety of places according to the specific packet */
2033     /* If we've already displayed it crc_length comes out 0 */
2034     crc_length = tvb_reported_length_remaining(tvb, offset);
2035     if(crc_length == 6)
2036     {
2037         proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset +=4;
2038         proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc,   tvb, offset, 2, ENC_BIG_ENDIAN); offset+=2;
2039     }
2040     else if(crc_length == 4)
2041     {
2042         proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset +=4;
2043     }
2044     else if(crc_length == 2)
2045     {
2046         proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc,   tvb, offset, 2, ENC_BIG_ENDIAN); offset+=2;
2047     }
2048
2049 }
2050
2051 static void
2052 dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2053 {
2054     /* Top Level Item */
2055     proto_item *infiniband_link_packet = NULL;
2056
2057     /* The Link Subtree */
2058     proto_tree *link_tree = NULL;
2059
2060     proto_item *operand_item = NULL;
2061     gint offset = 0;                /* Current Offset */
2062     guint8 operand;                 /* Link packet Operand */
2063
2064     /* allocate space for source/destination addresses if not allocated already. we will fill them in later */
2065     if (!src_addr)
2066         src_addr = ep_alloc(ADDR_MAX_LEN);
2067
2068     if (!dst_addr)
2069         dst_addr = ep_alloc(ADDR_MAX_LEN);
2070
2071     operand =  tvb_get_guint8(tvb, offset);
2072     operand = (operand & 0xF0) >> 4;
2073
2074     /* Mark the Packet type as Infiniband in the wireshark UI */
2075     /* Clear other columns */
2076     col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand Link");
2077     col_clear(pinfo->cinfo, COL_INFO);
2078     col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
2079              val_to_str(operand, Operand_Description, "Unknown (0x%1x)"));
2080
2081     /* Get the parent tree from the ERF dissector.  We don't want to nest under ERF */
2082     if(tree && tree->parent)
2083     {
2084         /* Set the normal tree outside of ERF */
2085         tree = tree->parent;
2086         /* Set a global reference for nested protocols */
2087         top_tree = tree;
2088     }
2089
2090     if(!tree)
2091     {
2092         /* If no packet details are being dissected, extract some high level info for the packet view */
2093         /* Assigns column values rather than full tree population */
2094         dissect_general_info(tvb, offset, pinfo, FALSE);
2095         return;
2096     }
2097
2098     /* Top Level Packet */
2099     infiniband_link_packet = proto_tree_add_item(tree, proto_infiniband_link, tvb, offset, -1, ENC_NA);
2100
2101     /* Headers Level Tree */
2102     link_tree = proto_item_add_subtree(infiniband_link_packet, ett_link);
2103
2104     operand_item = proto_tree_add_item(link_tree, hf_infiniband_link_op, tvb, offset, 2, ENC_BIG_ENDIAN);
2105
2106     if (operand > 1) {
2107         proto_item_set_text(operand_item, "%s", "Reserved");
2108         call_dissector(data_handle, tvb, pinfo, link_tree);
2109     } else {
2110         proto_tree_add_item(link_tree, hf_infiniband_link_fctbs, tvb, offset, 2, ENC_BIG_ENDIAN);
2111         offset += 2;
2112
2113         proto_tree_add_item(link_tree, hf_infiniband_link_vl, tvb, offset, 2, ENC_BIG_ENDIAN);
2114         proto_tree_add_item(link_tree, hf_infiniband_link_fccl, tvb, offset, 2, ENC_BIG_ENDIAN);
2115         offset += 2;
2116
2117         proto_tree_add_item(link_tree, hf_infiniband_link_lpcrc, tvb, offset, 2, ENC_BIG_ENDIAN);
2118         offset += 2;
2119     }
2120
2121 }
2122
2123
2124 /* Description: Finds the header sequence that follows the Base Transport Header.
2125 * Somwhat inefficient (should be using a single key,value pair data structure)
2126 * But uses pure probablity to take a stab at better efficiency.
2127 * Searches largest header sequence groups first, and then finally resorts to single matches for unique header sequences
2128 * IN: OpCode: The OpCode from the Base Transport Header.
2129 * OUT: The Header Sequence enumeration.  See Declarations for #defines from (0-22) */
2130 static gint32
2131 find_next_header_sequence(guint32 OpCode)
2132 {
2133     if(contains(OpCode, &opCode_PAYLD[0], (gint32)sizeof(opCode_PAYLD)))
2134         return PAYLD;
2135
2136     if(contains(OpCode, &opCode_IMMDT_PAYLD[0], (gint32)sizeof(opCode_IMMDT_PAYLD)))
2137         return IMMDT_PAYLD;
2138
2139     if(contains(OpCode, &opCode_RDETH_DETH_PAYLD[0], (gint32)sizeof(opCode_RDETH_DETH_PAYLD)))
2140         return RDETH_DETH_PAYLD;
2141
2142     if(contains(OpCode, &opCode_RETH_PAYLD[0], (gint32)sizeof(opCode_RETH_PAYLD)))
2143         return RETH_PAYLD;
2144
2145     if(contains(OpCode, &opCode_RDETH_AETH_PAYLD[0], (gint32)sizeof(opCode_RDETH_AETH_PAYLD)))
2146         return RDETH_AETH_PAYLD;
2147
2148     if(contains(OpCode, &opCode_AETH_PAYLD[0], (gint32)sizeof(opCode_AETH_PAYLD)))
2149         return AETH_PAYLD;
2150
2151     if(contains(OpCode, &opCode_RDETH_DETH_IMMDT_PAYLD[0], (gint32)sizeof(opCode_RDETH_DETH_IMMDT_PAYLD)))
2152         return RDETH_DETH_IMMDT_PAYLD;
2153
2154     if(contains(OpCode, &opCode_RETH_IMMDT_PAYLD[0], (gint32)sizeof(opCode_RETH_IMMDT_PAYLD)))
2155         return RETH_IMMDT_PAYLD;
2156
2157     if(contains(OpCode, &opCode_RDETH_DETH_RETH_PAYLD[0], (gint32)sizeof(opCode_RDETH_DETH_RETH_PAYLD)))
2158         return RDETH_DETH_RETH_PAYLD;
2159
2160     if(contains(OpCode, &opCode_ATOMICETH[0], (gint32)sizeof(opCode_ATOMICETH)))
2161         return ATOMICETH;
2162
2163     if(contains(OpCode, &opCode_IETH_PAYLD[0], (gint32)sizeof(opCode_IETH_PAYLD)))
2164         return IETH_PAYLD;
2165
2166     if(contains(OpCode, &opCode_RDETH_DETH_ATOMICETH[0], (gint32)sizeof(opCode_RDETH_DETH_ATOMICETH)))
2167         return RDETH_DETH_ATOMICETH;
2168
2169     if((OpCode ^ RC_ACKNOWLEDGE) == 0)
2170         return AETH;
2171
2172     if((OpCode ^ RC_RDMA_READ_REQUEST) == 0)
2173         return RETH;
2174
2175     if((OpCode ^ RC_ATOMIC_ACKNOWLEDGE) == 0)
2176         return AETH_ATOMICACKETH;
2177
2178     if((OpCode ^ RD_RDMA_READ_RESPONSE_MIDDLE) == 0)
2179         return RDETH_PAYLD;
2180
2181     if((OpCode ^ RD_ACKNOWLEDGE) == 0)
2182         return RDETH_AETH;
2183
2184     if((OpCode ^ RD_ATOMIC_ACKNOWLEDGE) == 0)
2185         return RDETH_AETH_ATOMICACKETH;
2186
2187     if((OpCode ^ RD_RDMA_WRITE_ONLY_IMM) == 0)
2188         return RDETH_DETH_RETH_IMMDT_PAYLD;
2189
2190     if((OpCode ^ RD_RDMA_READ_REQUEST) == 0)
2191         return RDETH_DETH_RETH;
2192
2193     if((OpCode ^ RD_RESYNC) == 0)
2194         return RDETH_DETH;
2195
2196     if((OpCode ^ UD_SEND_ONLY) == 0)
2197         return DETH_PAYLD;
2198
2199     if((OpCode ^ UD_SEND_ONLY_IMM) == 0)
2200         return DETH_IMMDT_PAYLD;
2201
2202     return -1;
2203 }
2204
2205 /* Description: Finds if a given value is present in an array. This is probably in a standard library somewhere,
2206 * But I'd rather define my own.
2207 * IN: OpCode: The OpCode you are looking for
2208 * IN: Codes: The organized array of OpCodes to look through
2209 * IN: Array length, because we're in C++...
2210 * OUT: Boolean indicating if that OpCode was found in OpCodes */
2211 static gboolean
2212 contains(guint32 OpCode, guint32* Codes, gint32 length)
2213 {
2214     gint32 i;
2215     for(i = 0; i < length; i++)
2216     {
2217         if((OpCode ^ Codes[i]) == 0)
2218             return TRUE;
2219     }
2220     return FALSE;
2221 }
2222
2223 /* Parse RDETH - Reliable Datagram Extended Transport Header
2224 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2225 * IN: tvb - the data buffer from wireshark
2226 * IN/OUT: The current and updated offset */
2227 static void
2228 parse_RDETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2229 {
2230     gint local_offset = *offset;
2231     /* RDETH - Reliable Datagram Extended Transport Header */
2232     proto_tree *RDETH_header_tree = NULL;
2233     proto_item *RDETH_header_item = NULL;
2234
2235     RDETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RDETH, tvb, local_offset, 4, ENC_NA);
2236     proto_item_set_text(RDETH_header_item, "%s", "RDETH - Reliable Datagram Extended Transport Header");
2237     RDETH_header_tree = proto_item_add_subtree(RDETH_header_item, ett_rdeth);
2238
2239     proto_tree_add_item(RDETH_header_tree, hf_infiniband_reserved8_RDETH,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
2240     proto_tree_add_item(RDETH_header_tree, hf_infiniband_ee_context,        tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
2241     *offset = local_offset;
2242 }
2243
2244 /* Parse DETH - Datagram Extended Transport Header
2245 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2246 * IN: tvb - the data buffer from wireshark
2247 * IN/OUT: The current and updated offset  */
2248 static void
2249 parse_DETH(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2250 {
2251     gint local_offset = *offset;
2252     /* DETH - Datagram Extended Transport Header */
2253     proto_tree *DETH_header_tree = NULL;
2254     proto_item *DETH_header_item = NULL;
2255
2256     DETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_DETH, tvb, local_offset, 8, ENC_NA);
2257     proto_item_set_text(DETH_header_item, "%s", "DETH - Datagram Extended Transport Header");
2258     DETH_header_tree = proto_item_add_subtree(DETH_header_item, ett_deth);
2259
2260     proto_tree_add_item(DETH_header_tree, hf_infiniband_queue_key,                  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
2261     proto_tree_add_item(DETH_header_tree, hf_infiniband_reserved8_DETH,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
2262     proto_tree_add_item(DETH_header_tree, hf_infiniband_source_qp,                  tvb, local_offset, 3, ENC_BIG_ENDIAN);
2263     pinfo->srcport = tvb_get_ntoh24(tvb, local_offset); local_offset+=3;
2264
2265     *offset = local_offset;
2266 }
2267
2268 /* Parse RETH - RDMA Extended Transport Header
2269 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2270 * IN: tvb - the data buffer from wireshark
2271 * IN/OUT: The current and updated offset */
2272 static void
2273 parse_RETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2274 {
2275     gint local_offset = *offset;
2276     /* RETH - RDMA Extended Transport Header */
2277     proto_tree *RETH_header_tree = NULL;
2278     proto_item *RETH_header_item = NULL;
2279
2280     RETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RETH, tvb, local_offset, 16, ENC_NA);
2281     proto_item_set_text(RETH_header_item, "%s", "RETH - RDMA Extended Transport Header");
2282     RETH_header_tree = proto_item_add_subtree(RETH_header_item, ett_reth);
2283
2284     proto_tree_add_item(RETH_header_tree, hf_infiniband_virtual_address,                tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2285     proto_tree_add_item(RETH_header_tree, hf_infiniband_remote_key,                     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
2286     proto_tree_add_item(RETH_header_tree, hf_infiniband_dma_length,                     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
2287
2288     *offset = local_offset;
2289 }
2290
2291 /* Parse AtomicETH - Atomic Extended Transport Header
2292 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2293 * IN: tvb - the data buffer from wireshark
2294 * IN/OUT: The current and updated offset */
2295 static void
2296 parse_ATOMICETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2297 {
2298     gint local_offset = *offset;
2299     /* AtomicETH - Atomic Extended Transport Header */
2300     proto_tree *ATOMICETH_header_tree = NULL;
2301     proto_item *ATOMICETH_header_item = NULL;
2302
2303     ATOMICETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicETH, tvb, local_offset, 28, ENC_NA);
2304     proto_item_set_text(ATOMICETH_header_item, "%s", "AtomicETH - Atomic Extended Transport Header");
2305     ATOMICETH_header_tree = proto_item_add_subtree(ATOMICETH_header_item, ett_atomiceth);
2306
2307     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_virtual_address,               tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2308     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_remote_key,                    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
2309     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_swap_or_add_data,              tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2310     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_compare_data,                  tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2311     *offset = local_offset;
2312 }
2313
2314 /* Parse AETH - ACK Extended Transport Header
2315 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2316 * IN: tvb - the data buffer from wireshark
2317 * IN/OUT: The current and updated offset */
2318 static void
2319 parse_AETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2320 {
2321     gint local_offset = *offset;
2322     /* AETH - ACK Extended Transport Header */
2323     proto_tree *AETH_header_tree = NULL;
2324     proto_item *AETH_header_item = NULL;
2325
2326     AETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AETH, tvb, local_offset, 4, ENC_NA);
2327     proto_item_set_text(AETH_header_item, "%s", "AETH - ACK Extended Transport Header");
2328     AETH_header_tree = proto_item_add_subtree(AETH_header_item, ett_aeth);
2329
2330     proto_tree_add_item(AETH_header_tree, hf_infiniband_syndrome,                       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
2331     proto_tree_add_item(AETH_header_tree, hf_infiniband_message_sequence_number,        tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
2332
2333     *offset = local_offset;
2334 }
2335
2336 /* Parse AtomicAckEth - Atomic ACK Extended Transport Header
2337 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2338 * IN: tvb - the data buffer from wireshark
2339 * IN/OUT: The current and updated offset */
2340 static void
2341 parse_ATOMICACKETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2342 {
2343     gint local_offset = *offset;
2344     /* AtomicAckEth - Atomic ACK Extended Transport Header */
2345     proto_tree *ATOMICACKETH_header_tree = NULL;
2346     proto_item *ATOMICACKETH_header_item = NULL;
2347
2348     ATOMICACKETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicAckETH, tvb, local_offset, 8, ENC_NA);
2349     proto_item_set_text(ATOMICACKETH_header_item, "%s", "ATOMICACKETH - Atomic ACK Extended Transport Header");
2350     ATOMICACKETH_header_tree = proto_item_add_subtree(ATOMICACKETH_header_item, ett_atomicacketh);
2351     proto_tree_add_item(ATOMICACKETH_header_tree, hf_infiniband_original_remote_data,   tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2352     *offset = local_offset;
2353 }
2354
2355 /* Parse IMMDT - Immediate Data Extended Transport Header
2356 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2357 * IN: tvb - the data buffer from wireshark
2358 * IN/OUT: The current and updated offset */
2359 static void
2360 parse_IMMDT(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2361 {
2362     gint local_offset = *offset;
2363     /* IMMDT - Immediate Data Extended Transport Header */
2364     proto_tree *IMMDT_header_tree = NULL;
2365     proto_item *IMMDT_header_item = NULL;
2366
2367     IMMDT_header_item = proto_tree_add_item(parentTree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA);
2368     proto_item_set_text(IMMDT_header_item, "%s", "IMMDT - Immediate Data Extended Transport Header");
2369     IMMDT_header_tree = proto_item_add_subtree(IMMDT_header_item, ett_immdt);
2370     proto_tree_add_item(IMMDT_header_tree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA); local_offset+=4;
2371     *offset = local_offset;
2372 }
2373
2374 /* Parse IETH - Invalidate Extended Transport Header
2375 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2376 * IN: tvb - the data buffer from wireshark
2377 * IN/OUT: The current and updated offset */
2378 static void
2379 parse_IETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2380 {
2381     gint local_offset = *offset;
2382     /* IETH - Invalidate Extended Transport Header */
2383     proto_tree *IETH_header_tree = NULL;
2384     proto_item *IETH_header_item = NULL;
2385
2386     IETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_IETH, tvb, local_offset, 4, ENC_NA);
2387     proto_item_set_text(IETH_header_item, "%s", "IETH - Invalidate Extended Transport Header");
2388     IETH_header_tree = proto_item_add_subtree(IETH_header_item, ett_ieth);
2389
2390     proto_tree_add_item(IETH_header_tree, hf_infiniband_IETH,   tvb, local_offset, 4, ENC_NA); local_offset+=4;
2391
2392     *offset = local_offset;
2393 }
2394
2395 /* Parse Payload - Packet Payload / Invariant CRC / Variant CRC
2396 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2397 * IN: pinfo - packet info from wireshark
2398 * IN: tvb - the data buffer from wireshark
2399 * IN/OUT: offset - The current and updated offset
2400 * IN: length - Length of Payload */
2401 static void parse_PAYLOAD(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset, gint length)
2402 {
2403     gint local_offset = *offset;
2404     /* Payload - Packet Payload */
2405     proto_tree *PAYLOAD_header_tree = NULL;
2406     proto_item *PAYLOAD_header_item = NULL;
2407     guint8 management_class;
2408     tvbuff_t *volatile next_tvb;
2409     gint            captured_length, reported_length;
2410     guint16 etype, reserved;
2411     const char      *saved_proto;
2412     volatile gboolean   dissector_found = FALSE;
2413
2414     if(!tvb_bytes_exist(tvb, *offset, length)) /* previously consumed bytes + offset was all the data - none or corrupt payload */
2415     {
2416         col_set_str(pinfo->cinfo, COL_INFO, "Invalid Packet Length from LRH! [Malformed Packet]");
2417         col_set_fence(pinfo->cinfo, COL_INFO);
2418         return;
2419     }
2420
2421     /* management datagrams are determined by the source/destination QPs */
2422     if (pinfo->srcport == 0 || pinfo->srcport == 1 || pinfo->destport == 0 || pinfo->destport == 1)    /* management datagram */
2423     {
2424         management_class =  tvb_get_guint8(tvb, (*offset) + 1);
2425
2426         if(((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END))
2427             || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END)))
2428         {
2429             /* parse vendor specific */
2430             parse_VENDOR_MANAGEMENT(parentTree, tvb, offset);
2431         }
2432         else if((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END))
2433         {
2434             /* parse application specific */
2435             parse_APPLICATION_MANAGEMENT(parentTree, tvb, offset);
2436         }
2437         else if(((management_class == (guint8)0x00) || (management_class == (guint8)0x02))
2438             || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80))
2439             || ((management_class >= (guint8)0x82)))
2440         {
2441             /* parse reserved classes */
2442             parse_RESERVED_MANAGEMENT(parentTree, tvb, offset);
2443         }
2444         else /* we have a normal management_class */
2445         {
2446             switch(management_class)
2447             {
2448                 case SUBN_LID_ROUTED:
2449                     /* parse subn man lid routed */
2450                     parse_SUBN_LID_ROUTED(parentTree, pinfo, tvb, &local_offset);
2451                 break;
2452                 case SUBN_DIRECTED_ROUTE:
2453                     /* parse subn directed route */
2454                     parse_SUBN_DIRECTED_ROUTE(parentTree, pinfo, tvb, &local_offset);
2455                 break;
2456                 case SUBNADMN:
2457                     /* parse sub admin */
2458                     parse_SUBNADMN(parentTree, pinfo, tvb, &local_offset);
2459                 break;
2460                 case PERF:
2461                     /* parse performance */
2462                     parse_PERF(parentTree, tvb, pinfo, &local_offset);
2463                 break;
2464                 case BM:
2465                     /* parse baseboard mgmt */
2466                     parse_BM(parentTree, tvb, &local_offset);
2467                 break;
2468                 case DEV_MGT:
2469                     /* parse device management */
2470                     parse_DEV_MGT(parentTree, tvb, &local_offset);
2471                 break;
2472                 case COM_MGT:
2473                     /* parse communication management */
2474                     parse_COM_MGT(parentTree, pinfo, tvb, &local_offset);
2475                 break;
2476                 case SNMP:
2477                     /* parse snmp tunneling */
2478                     parse_SNMP(parentTree, tvb, &local_offset);
2479                 break;
2480                 default:
2481                     break;
2482             }
2483         }
2484     }
2485     else /* Normal Data Packet - Parse as such */
2486     {
2487
2488         /* Calculation for Payload:
2489         * (tvb_length) Length of entire packet - (local_offset) Starting byte of Payload Data
2490         * offset addition is more complex for the payload.
2491         * We need the total length of the packet, - length of previous headers, + offset where payload started.
2492         * We also need  to reserve 6 bytes for the CRCs which are not actually part of the payload.  */
2493
2494         etype = tvb_get_ntohs(tvb, local_offset);
2495         reserved =  tvb_get_ntohs(tvb, local_offset + 2);
2496
2497         /* try to recognize whether or not this is a Mellanox EoIB packet by the
2498            transport type and the 4 first bits of the payload */
2499         if      (pref_dissect_eoib &&
2500                  transport_type == TRANSPORT_UD &&
2501                  tvb_get_bits8(tvb, local_offset*8, 4) == 0xC) {
2502             dissector_found = parse_EoIB(parentTree, tvb, local_offset, pinfo);
2503         }
2504
2505         /* IBA packet data could be anything in principle, however it is common
2506          * practice to carry non-IBA data encapsulated with an EtherType header,
2507          * similar to the RWH header. There is no way to identify these frames
2508          * positively.
2509          *
2510          * If the appropriate option is set in protocol preferences,
2511          * We see if the first few bytes look like an EtherType header, and if so
2512          * call the appropriate dissector. If not we call the "data" dissector.
2513          */
2514         if (!dissector_found && pref_identify_iba_payload && reserved == 0) {
2515             void *pd_save;
2516
2517             /* Get the captured length and reported length of the data
2518                after the Ethernet type. */
2519             captured_length = tvb_length_remaining(tvb, local_offset+4);
2520             reported_length = tvb_reported_length_remaining(tvb,
2521                                     local_offset+4);
2522
2523             next_tvb = tvb_new_subset(tvb, local_offset+4, captured_length,
2524                           reported_length);
2525
2526             pinfo->ethertype = etype;
2527
2528             /* Look for sub-dissector, and call it if found.
2529                Catch exceptions, so that if the reported length of "next_tvb"
2530                was reduced by some dissector before an exception was thrown,
2531                we can still put in an item for the trailer. */
2532             saved_proto = pinfo->current_proto;
2533             pd_save = pinfo->private_data;
2534
2535             TRY {
2536                 dissector_found = dissector_try_uint(ethertype_dissector_table,
2537                                      etype, next_tvb, pinfo, top_tree);
2538             }
2539             CATCH(BoundsError) {
2540                 /* Somebody threw BoundsError, which means that:
2541
2542                 1) a dissector was found, so we don't need to
2543                 dissect the payload as data or update the
2544                 protocol or info columns;
2545
2546                 2) dissecting the payload found that the packet was
2547                 cut off by a snapshot length before the end of
2548                 the payload.  The trailer comes after the payload,
2549                 so *all* of the trailer is cut off, and we'll
2550                 just get another BoundsError if we add the trailer.
2551
2552                 Therefore, we just rethrow the exception so it gets
2553                 reported; we don't dissect the trailer or do anything
2554                 else. */
2555                 RETHROW;
2556             }
2557             CATCH(OutOfMemoryError) {
2558                 RETHROW;
2559             }
2560             CATCH_ALL {
2561                 /* Somebody threw an exception other than BoundsError, which
2562                    means that a dissector was found, so we don't need to
2563                    dissect the payload as data or update the protocol or info
2564                    columns.  We just show the exception and then drive on
2565                    to show the trailer, after noting that a dissector was
2566                    found and restoring the protocol value that was in effect
2567                    before we called the subdissector. */
2568
2569                 /*  Restore the private_data structure in case one of the
2570                  *  called dissectors modified it (and, due to the exception,
2571                  *  was unable to restore it).
2572                  */
2573                 pinfo->private_data = pd_save;
2574
2575                 show_exception(next_tvb, pinfo, top_tree, EXCEPT_CODE, GET_MESSAGE);
2576                 dissector_found = TRUE;
2577                 pinfo->current_proto = saved_proto;
2578             }
2579             ENDTRY;
2580
2581             if (dissector_found) {
2582                 /* now create payload entry to show Ethertype */
2583                 PAYLOAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_payload, tvb, local_offset, tvb_reported_length_remaining(tvb, local_offset)-6, ENC_NA);
2584                 proto_item_set_text(PAYLOAD_header_item, "%s", "IBA Payload - appears to be EtherType encapsulated");
2585                 PAYLOAD_header_tree = proto_item_add_subtree(PAYLOAD_header_item, ett_payload);
2586                 proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_etype, tvb,
2587                             local_offset, 2,  tvb_get_ntohs(tvb, local_offset));
2588
2589                 local_offset += 2;
2590
2591                 proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_reserved16_RWH, tvb,
2592                             local_offset, 2, tvb_get_ntohs(tvb, local_offset));
2593
2594             }
2595
2596         }
2597
2598         captured_length = tvb_length_remaining(tvb, local_offset);
2599         reported_length = tvb_reported_length_remaining(tvb,
2600                                 local_offset);
2601
2602         if (reported_length >= 6)
2603             reported_length -= 6;
2604         if (captured_length > reported_length)
2605             captured_length = reported_length;
2606
2607         next_tvb = tvb_new_subset(tvb, local_offset,
2608                       captured_length,
2609                       reported_length);
2610
2611         /* Try any heuristic dissectors that requested a chance to try and dissect IB payloads */
2612         if (!dissector_found) {
2613             dissector_found = dissector_try_heuristic(heur_dissectors_payload, next_tvb, pinfo, parentTree);
2614         }
2615
2616         if (!dissector_found) {
2617             /* No sub-dissector found.
2618                Label rest of packet as "Data" */
2619             call_dissector(data_handle, next_tvb, pinfo, top_tree);
2620
2621         }
2622
2623
2624         /*parse_RWH(parentTree, tvb, &local_offset, pinfo);*/
2625
2626         /* Will contain ICRC and VCRC = 4+2 */
2627         local_offset = tvb_reported_length(tvb) - 6;
2628     }
2629
2630     *offset = local_offset;
2631 }
2632
2633 /* Parse VENDOR - Parse a vendor specific or unknown header sequence
2634 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2635 * IN: tvb - the data buffer from wireshark
2636 * IN/OUT: The current and updated offset */
2637 static void parse_VENDOR(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2638 {
2639     gint local_offset = *offset;
2640     proto_tree *VENDOR_header_tree = NULL;
2641     proto_item *VENDOR_header_item = NULL;
2642
2643     VENDOR_header_item = proto_tree_add_item(parentTree, hf_infiniband_vendor, tvb, local_offset, 4, ENC_NA);
2644     proto_item_set_text(VENDOR_header_item, "%s", "Vendor Specific or Unknown Header Sequence");
2645     VENDOR_header_tree = proto_item_add_subtree(VENDOR_header_item, ett_vendor);
2646     proto_tree_add_item(VENDOR_header_tree, hf_infiniband_vendor,   tvb, local_offset, -1, ENC_NA);
2647     *offset = local_offset;
2648 }
2649
2650 /* Parse IPv6 - Parse an IPv6 Packet
2651 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2652 * IN: tvb - the data buffer from wireshark
2653 * IN/OUT: The current and updated offset
2654 * IN: pinfo - packet info from wireshark */
2655 static void parse_IPvSix(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, packet_info *pinfo)
2656 {
2657     tvbuff_t *ipv6_tvb;
2658
2659     /* (- 2) for VCRC which lives at the end of the packet   */
2660     ipv6_tvb = tvb_new_subset(tvb, *offset,
2661                   tvb_length_remaining(tvb, *offset) - 2,
2662                   tvb_reported_length_remaining(tvb, *offset) - 2);
2663     call_dissector(ipv6_handle, ipv6_tvb, pinfo, parentTree);
2664     *offset = tvb_reported_length(tvb) - 2;
2665
2666     /* Display the VCRC */
2667     proto_tree_add_item(parentTree, hf_infiniband_variant_crc,  tvb, *offset, 2, ENC_BIG_ENDIAN);
2668 }
2669
2670 /* Parse EtherType - Parse a generic IP packaet with an EtherType of IP or ARP
2671 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2672 * IN: tvb - the data buffer from wireshark
2673 * IN/OUT: The current and updated offset
2674 * IN: pinfo - packet info from wireshark */
2675 static void parse_RWH(proto_tree *ah_tree, tvbuff_t *tvb, gint *offset, packet_info *pinfo)
2676 {
2677     guint16 ether_type;
2678     tvbuff_t *next_tvb;
2679
2680     /* RWH - Raw Header */
2681     proto_tree *RWH_header_tree = NULL;
2682     proto_item *RWH_header_item = NULL;
2683
2684     gint captured_length, reported_length;
2685
2686     RWH_header_item = proto_tree_add_item(ah_tree, hf_infiniband_RWH, tvb, *offset, 4, ENC_NA);
2687     proto_item_set_text(RWH_header_item, "%s", "RWH - Raw Header");
2688     RWH_header_tree = proto_item_add_subtree(RWH_header_item, ett_rwh);
2689
2690     proto_tree_add_item(RWH_header_tree, hf_infiniband_reserved16_RWH, tvb,
2691             *offset, 2, ENC_BIG_ENDIAN);
2692
2693     *offset += 2;
2694
2695     ether_type = tvb_get_ntohs(tvb, *offset);
2696     proto_tree_add_uint(RWH_header_tree, hf_infiniband_etype, tvb, *offset, 2,
2697                         ether_type);
2698     *offset += 2;
2699
2700     /* Get the captured length and reported length of the data
2701      * after the Ethernet type. */
2702     captured_length = tvb_length_remaining(tvb, *offset);
2703     reported_length = tvb_reported_length_remaining(tvb, *offset);
2704
2705     /* Construct a tvbuff for the payload after the Ethernet type,
2706      * not including the FCS. */
2707     if (captured_length >= 0 && reported_length >= 0) {
2708         if (reported_length >= 2)
2709             reported_length -= 2;
2710         if (captured_length > reported_length)
2711             captured_length = reported_length;
2712     }
2713
2714     next_tvb = tvb_new_subset(tvb, *offset, captured_length, reported_length);
2715     if (!dissector_try_uint(ethertype_dissector_table, ether_type,
2716             next_tvb, pinfo, top_tree))
2717        call_dissector(data_handle, next_tvb, pinfo, top_tree);
2718
2719     *offset = tvb_reported_length(tvb) - 2;
2720     /* Display the VCRC */
2721     proto_tree_add_item(ah_tree, hf_infiniband_variant_crc, tvb, *offset, 2, ENC_BIG_ENDIAN);
2722 }
2723
2724
2725 /* Parse a Mellanox EoIB Encapsulation Header and the associated Ethernet frame
2726 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2727 * IN: tvb - the data buffer from wireshark
2728 * IN: The current offset
2729 * IN: pinfo - packet info from wireshark */
2730 static gboolean parse_EoIB(proto_tree *tree, tvbuff_t *tvb, gint offset, packet_info *pinfo)
2731 {
2732     proto_item *header_item;
2733     proto_tree *header_subtree;
2734     gboolean ms;
2735     gint8 seg_offset;
2736     tvbuff_t *encap_tvb;
2737     /* the encapsulated eoib size (including the header!) is remaining length-6 bytes of CRC */
2738     int encap_size = tvb_reported_length_remaining(tvb, offset) - 6;
2739
2740     if (encap_size < 4) {
2741         /* not even large enough to contain the eoib encap header. error! */
2742         return FALSE;
2743     }
2744
2745     encap_tvb = tvb_new_subset(tvb, offset + 4, tvb_length_remaining(tvb, offset + 4), encap_size - 4);
2746
2747     header_item = proto_tree_add_item(tree, hf_infiniband_EOIB, tvb, offset, 4, ENC_NA);
2748     header_subtree = proto_item_add_subtree(header_item, ett_eoib);
2749
2750     proto_tree_add_item(header_subtree, hf_infiniband_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
2751     proto_tree_add_item(header_subtree, hf_infiniband_tcp_chk, tvb, offset, 2, ENC_BIG_ENDIAN);
2752     proto_tree_add_item(header_subtree, hf_infiniband_ip_chk, tvb, offset, 2, ENC_BIG_ENDIAN);
2753     proto_tree_add_item(header_subtree, hf_infiniband_fcs, tvb, offset, 2, ENC_BIG_ENDIAN);
2754
2755     ms = tvb_get_bits8(tvb, (offset + 1)*8 + 2, 1);
2756     seg_offset = tvb_get_bits8(tvb, (offset + 1)*8 + 3, 5);
2757
2758     proto_tree_add_item(header_subtree, hf_infiniband_ms, tvb, offset, 2, ENC_BIG_ENDIAN);
2759     proto_tree_add_item(header_subtree, hf_infiniband_seg_off, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
2760     proto_tree_add_item(header_subtree, hf_infiniband_seg_id, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
2761
2762     if (seg_offset || ms) {
2763         /* this is a fragment of an encapsulated Ethernet jumbo frame, parse as data */
2764         call_dissector(data_handle, encap_tvb, pinfo, top_tree);
2765     } else {
2766         /* non-fragmented frames can be fully parsed */
2767         call_dissector(eth_handle, encap_tvb, pinfo, top_tree);
2768     }
2769
2770     return TRUE;
2771 }
2772
2773
2774 /* Parse Subnet Management (LID Routed)
2775 * IN: parentTree to add the dissection to
2776 * IN: pinfo - packet info from wireshark
2777 * IN: tvb - the data buffer from wireshark
2778 * IN/OUT: The current and updated offset */
2779 static void parse_SUBN_LID_ROUTED(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2780 {
2781     /* Parse the Common MAD Header */
2782     MAD_Data MadData;
2783     gint local_offset;
2784     proto_tree *SUBN_LID_ROUTED_header_tree = NULL;
2785     proto_item *SUBN_LID_ROUTED_header_item = NULL;
2786
2787     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2788     {
2789         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2790         return;
2791     }
2792
2793     local_offset = *offset;
2794
2795     /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section. */
2796     SUBN_LID_ROUTED_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_LID, tvb, local_offset - 24, 256, ENC_NA);
2797     proto_item_set_text(SUBN_LID_ROUTED_header_item, "%s", "SMP (LID Routed) ");
2798     SUBN_LID_ROUTED_header_tree = proto_item_add_subtree(SUBN_LID_ROUTED_header_item, ett_subn_lid_routed);
2799     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_m_key,           tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
2800     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved256,     tvb, local_offset, 32, ENC_NA); local_offset +=32;
2801
2802     label_SUBM_Method(SUBN_LID_ROUTED_header_item, &MadData, pinfo);
2803     label_SUBM_Attribute(SUBN_LID_ROUTED_header_item, &MadData, pinfo);
2804
2805     /* Try to do the detail parse of the attribute.  If there is an error, or the attribute is unknown, we'll just highlight the generic data. */
2806     if(!parse_SUBM_Attribute(SUBN_LID_ROUTED_header_tree, tvb, &local_offset, &MadData))
2807     {
2808         proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_smp_data,    tvb, local_offset, 64, ENC_NA); local_offset +=64;
2809     }
2810
2811     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved1024,    tvb, local_offset, 128, ENC_NA); local_offset +=128;
2812     *offset = local_offset;
2813 }
2814
2815 /* Parse Subnet Management (Directed Route)
2816 * IN: parentTree to add the dissection to
2817 * IN: tvb - the data buffer from wireshark
2818 * IN/OUT: The current and updated offset */
2819 static void parse_SUBN_DIRECTED_ROUTE(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2820 {
2821     /* Parse the Common MAD Header */
2822     MAD_Data MadData;
2823     gint local_offset;
2824     proto_tree *SUBN_DIRECTED_ROUTE_header_tree = NULL;
2825     proto_item *SUBN_DIRECTED_ROUTE_header_item = NULL;
2826
2827     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2828     {
2829         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2830         return;
2831     }
2832
2833     local_offset = *offset;
2834
2835     /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section.
2836     * We need to go backwards because this particular SMP uses the class specific portion of the Common MAD Header */
2837     SUBN_DIRECTED_ROUTE_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_DIRECTED, tvb, local_offset - 24, 256, ENC_NA);
2838     proto_item_set_text(SUBN_DIRECTED_ROUTE_header_item, "%s", "SMP (Directed Route) ");
2839     SUBN_DIRECTED_ROUTE_header_tree = proto_item_add_subtree(SUBN_DIRECTED_ROUTE_header_item, ett_subn_directed_route);
2840
2841     label_SUBM_Method(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo);
2842     label_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo);
2843
2844     /* Place us at offset 4, the "D" Bit (Direction bit for Directed Route SMPs) */
2845     local_offset -= 20;
2846     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_d,               tvb, local_offset, 1, ENC_BIG_ENDIAN);
2847     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_status,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
2848     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_pointer,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
2849     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_count,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
2850     local_offset += 16; /* Skip over the rest of the Common MAD Header... It's already dissected by parse_MAD_Common */
2851     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_m_key,           tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
2852     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_slid,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
2853     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_dlid,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
2854     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_reserved28,      tvb, local_offset, 28, ENC_NA); local_offset +=28;
2855
2856     /* Try to do the detail parse of the attribute.  If there is an error, or the attribute is unknown, we'll just highlight the generic data. */
2857     if(!parse_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_tree, tvb, &local_offset, &MadData))
2858     {
2859         proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_data,    tvb, local_offset, 64, ENC_NA); local_offset +=64;
2860     }
2861
2862     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_initial_path,        tvb, local_offset, 64, ENC_NA); local_offset +=64;
2863     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_return_path,     tvb, local_offset, 64, ENC_NA); local_offset +=64;
2864     *offset = local_offset;
2865 }
2866
2867 /* Parse Subnet Administration
2868 * IN: parentTree to add the dissection to
2869 * IN: pinfo - packet info from wireshark
2870 * IN: tvb - the data buffer from wireshark
2871 * IN/OUT: The current and updated offset */
2872 static void parse_SUBNADMN(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2873 {
2874     /* Parse the Common MAD Header */
2875     MAD_Data MadData;
2876     gint local_offset;
2877     proto_tree *SUBNADMN_header_tree = NULL;
2878     proto_item *SUBNADMN_header_item = NULL;
2879
2880     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2881     {
2882         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2883         return;
2884     }
2885     if(!parse_RMPP(parentTree, tvb, offset))
2886     {
2887         /* TODO: Mark Corrupt Packet */
2888         return;
2889     }
2890     local_offset = *offset;
2891
2892     SUBNADMN_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset - 36, 256, ENC_NA);
2893     proto_item_set_text(SUBNADMN_header_item, "%s", "SMA");
2894     SUBNADMN_header_tree = proto_item_add_subtree(SUBNADMN_header_item, ett_subnadmin);
2895
2896     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_sm_key,             tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2897     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_attribute_offset,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=4;
2898     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_reserved16,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=4;
2899     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_component_mask,     tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
2900
2901     label_SUBA_Method(SUBNADMN_header_item, &MadData, pinfo);
2902     label_SUBA_Attribute(SUBNADMN_header_item, &MadData, pinfo);
2903
2904     if(!parse_SUBA_Attribute(SUBNADMN_header_tree, tvb, &local_offset, &MadData))
2905     {
2906         proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_subnet_admin_data,  tvb, local_offset, 200, ENC_NA); local_offset+=200;
2907     }
2908     *offset = local_offset;
2909 }
2910
2911 /* Parse Performance Management
2912 * IN: parentTree to add the dissection to
2913 * IN: tvb - the data buffer from wireshark
2914 * IN: pinfo - the pinfo struct from wireshark
2915 * IN/OUT: The current and updated offset */
2916 static void parse_PERF(proto_tree *parentTree, tvbuff_t *tvb, packet_info *pinfo, gint *offset)
2917 {
2918     /* Parse the Common MAD Header */
2919     MAD_Data MadData;
2920     gint local_offset;
2921     proto_item *PERF_header_item = NULL;
2922
2923     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2924     {
2925         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2926         return;
2927     }
2928
2929     local_offset = *offset; /* offset now points to the start of the MAD data field */
2930
2931     switch (MadData.attributeID) {
2932         case ATTR_PORT_COUNTERS:
2933             parse_PERF_PortCounters(parentTree, tvb, pinfo, &local_offset);
2934             break;
2935         case ATTR_PORT_COUNTERS_EXT:
2936             parse_PERF_PortCountersExtended(parentTree, tvb, pinfo, &local_offset);
2937             break;
2938         default:
2939             PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2940             proto_item_set_text(PERF_header_item, "%s", "PERF - Performance Management MAD (Dissector Not Implemented)");
2941             break;
2942     }
2943
2944     *offset = local_offset;
2945 }
2946
2947 /* Parse Baseboard Management
2948 * IN: parentTree to add the dissection to
2949 * IN: tvb - the data buffer from wireshark
2950 * IN/OUT: The current and updated offset */
2951 static void parse_BM(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
2952 {
2953     /* Parse the Common MAD Header */
2954     MAD_Data MadData;
2955     gint local_offset;
2956     proto_item *PERF_header_item = NULL;
2957
2958     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2959     {
2960         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2961         return;
2962     }
2963     local_offset = *offset;
2964
2965     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2966     proto_item_set_text(PERF_header_item, "%s", "BM - Baseboard Management MAD (Dissector Not Implemented)");
2967     *offset = local_offset;
2968 }
2969
2970 /* Parse Device Management
2971 * IN: parentTree to add the dissection to
2972 * IN: tvb - the data buffer from wireshark
2973 * IN/OUT: The current and updated offset */
2974 static void parse_DEV_MGT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
2975 {
2976     /* Parse the Common MAD Header */
2977     MAD_Data MadData;
2978     gint local_offset;
2979     proto_item *PERF_header_item = NULL;
2980
2981     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2982     {
2983         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2984         return;
2985     }
2986     local_offset = *offset;
2987     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2988     proto_item_set_text(PERF_header_item, "%s", "DEV_MGT - Device Management MAD (Dissector Not Implemented)");
2989     *offset = local_offset;
2990 }
2991
2992 /* Parse Communications Management
2993 * IN: parentTree to add the dissection to
2994 * IN: tvb - the data buffer from wireshark
2995 * IN/OUT: The current and updated offset */
2996 static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2997 {
2998     MAD_Data MadData;
2999     gint local_offset;
3000     guint32 local_qpn = 0, remote_qpn = 0;
3001     guint8 *local_gid, *remote_gid;
3002     guint32 local_lid, remote_lid;
3003     guint64 serviceid;
3004     const char *label = NULL;
3005     proto_item *CM_header_item = NULL;
3006     proto_tree *CM_header_tree = NULL;
3007     connection_context *connection = NULL; /* we'll use this to store new connections this CM packet is establishing*/
3008     tvbuff_t *next_tvb;
3009
3010     local_gid = ep_alloc(GID_SIZE);
3011     remote_gid = ep_alloc(GID_SIZE);
3012
3013     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3014     {
3015         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3016         return;
3017     }
3018     local_offset = *offset;
3019
3020     CM_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 140, ENC_NA);
3021
3022     label = val_to_str(MadData.attributeID, CM_Attributes, "(Unknown CM Attribute)");
3023
3024     proto_item_set_text(CM_header_item, "CM %s", label);
3025     col_clear(pinfo->cinfo, COL_INFO);
3026     col_append_fstr(pinfo->cinfo, COL_INFO, "CM: %s", label);
3027
3028     CM_header_tree = proto_item_add_subtree(CM_header_item, ett_cm);
3029
3030     switch (MadData.attributeID) {
3031         case ATTR_CM_REQ:
3032             proto_tree_add_item(CM_header_tree, hf_cm_req_local_comm_id, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3033             local_offset += 4;  /* skip reserved */
3034             proto_tree_add_item(CM_header_tree, hf_cm_req_service_id, tvb, local_offset, 8, ENC_BIG_ENDIAN);
3035             serviceid = tvb_get_ntoh64(tvb, local_offset); local_offset += 8;
3036             proto_tree_add_item(CM_header_tree, hf_cm_req_local_ca_guid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3037             local_offset += 4;  /* skip reserved */
3038             proto_tree_add_item(CM_header_tree, hf_cm_req_local_qkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3039             proto_tree_add_item(CM_header_tree, hf_cm_req_local_qpn, tvb, local_offset, 3, ENC_BIG_ENDIAN);
3040             local_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3;
3041             proto_tree_add_item(CM_header_tree, hf_cm_req_respo_res, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3042             proto_tree_add_item(CM_header_tree, hf_cm_req_local_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3043             proto_tree_add_item(CM_header_tree, hf_cm_req_init_depth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3044             proto_tree_add_item(CM_header_tree, hf_cm_req_remote_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3045             proto_tree_add_item(CM_header_tree, hf_cm_req_remote_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3046             proto_tree_add_item(CM_header_tree, hf_cm_req_transp_serv_type, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3047             proto_tree_add_item(CM_header_tree, hf_cm_req_e2e_flow_ctrl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3048             proto_tree_add_item(CM_header_tree, hf_cm_req_start_psn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3049             proto_tree_add_item(CM_header_tree, hf_cm_req_local_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3050             proto_tree_add_item(CM_header_tree, hf_cm_req_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3051             proto_tree_add_item(CM_header_tree, hf_cm_req_pkey, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3052             proto_tree_add_item(CM_header_tree, hf_cm_req_path_pp_mtu, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3053             proto_tree_add_item(CM_header_tree, hf_cm_req_rdc_exists, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3054             proto_tree_add_item(CM_header_tree, hf_cm_req_rnr_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3055             proto_tree_add_item(CM_header_tree, hf_cm_req_max_cm_retries, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3056             proto_tree_add_item(CM_header_tree, hf_cm_req_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3057             local_offset += 1;  /* skip reserved */
3058             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN);
3059             local_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2;
3060             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN);
3061             remote_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2;
3062             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_gid, tvb, local_offset, 16, ENC_NA);
3063             tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)local_gid); local_offset += 16;
3064             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_gid, tvb, local_offset, 16, ENC_NA);
3065             tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)remote_gid); local_offset += 16;
3066             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3067             local_offset += 1;  /* skip reserved */
3068             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3069             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3070             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3071             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_sl, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3072             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3073             local_offset += 1;  /* skip reserved */
3074             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_ack_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3075             local_offset += 1;  /* skip reserved */
3076             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3077             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3078             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16;
3079             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16;
3080             proto_tree_add_item(CM_header_tree, hf_cm_req_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3081             local_offset += 1;  /* skip reserved */
3082             proto_tree_add_item(CM_header_tree, hf_cm_req_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3083             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3084             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3085             proto_tree_add_item(CM_header_tree, hf_cm_req_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3086             proto_tree_add_item(CM_header_tree, hf_cm_req_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3087             local_offset += 1;  /* skip reserved */
3088             proto_tree_add_item(CM_header_tree, hf_cm_req_local_ACK_timeout, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3089             local_offset += 1;  /* skip reserved */
3090
3091             /* the following saves information about the conversation this packet defines,
3092                so there's no point in doing it more than once per packet */
3093             if(!pinfo->fd->flags.visited)
3094             {
3095                 conversation_t *conv;
3096                 conversation_infiniband_data *proto_data = NULL;
3097                 guint64 *hash_key = g_malloc(sizeof(guint64));
3098
3099                 /* create a new connection context and store it in the hash table */
3100                 connection = g_malloc(sizeof(connection_context));
3101                 memcpy(&(connection->req_gid), local_gid, GID_SIZE);
3102                 memcpy(&(connection->resp_gid), remote_gid, GID_SIZE);
3103                 connection->req_lid = local_lid;
3104                 connection->resp_lid = remote_lid;
3105                 connection->req_qp = local_qpn;
3106                 connection->resp_qp = 0;   /* not currently known. we'll fill this in later */
3107                 connection->service_id = serviceid;
3108
3109                 /* save the context to the context hash table, for retrieval when the corresponding
3110                    CM REP message arrives*/
3111                 *hash_key = MadData.transactionID;
3112                 ADD_ADDRESS_TO_HASH(*hash_key, &pinfo->src);
3113                 g_hash_table_replace(CM_context_table, hash_key, connection);
3114
3115                 /* Now we create a conversation for the CM exchange. This uses both
3116                    sides of the conversation since CM packets also include the source
3117                    QPN */
3118                 proto_data = se_alloc(sizeof(conversation_infiniband_data));
3119                 proto_data->service_id = connection->service_id;
3120
3121                 conv = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
3122                                         PT_IBQP, pinfo->srcport, pinfo->destport, 0);
3123                 conversation_add_proto_data(conv, proto_infiniband, proto_data);
3124             }
3125
3126             /* give a chance for subdissectors to analyze the private data */
3127             next_tvb = tvb_new_subset(tvb, local_offset, 92, -1);
3128             if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree) )
3129                 /* if none reported success, add this as raw "data" */
3130                 proto_tree_add_item(CM_header_tree, hf_cm_req_private_data, tvb, local_offset, 92, ENC_NA);
3131
3132             local_offset += 92;
3133             break;
3134         case ATTR_CM_REP:
3135             proto_tree_add_item(CM_header_tree, hf_cm_rep_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3136             proto_tree_add_item(CM_header_tree, hf_cm_rep_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3137             proto_tree_add_item(CM_header_tree, hf_cm_rep_localqkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3138             proto_tree_add_item(CM_header_tree, hf_cm_rep_localqpn, tvb, local_offset, 3, ENC_BIG_ENDIAN);
3139             remote_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3;
3140             local_offset += 1;  /* skip reserved */
3141             proto_tree_add_item(CM_header_tree, hf_cm_rep_localeecontnum, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3142             local_offset += 1;  /* skip reserved */
3143             proto_tree_add_item(CM_header_tree, hf_cm_rep_startingpsn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3144             local_offset += 1;  /* skip reserved */
3145             proto_tree_add_item(CM_header_tree, hf_cm_rep_responderres, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3146             proto_tree_add_item(CM_header_tree, hf_cm_rep_initiatordepth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3147             proto_tree_add_item(CM_header_tree, hf_cm_rep_tgtackdelay, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3148             proto_tree_add_item(CM_header_tree, hf_cm_rep_failoveracc, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3149             proto_tree_add_item(CM_header_tree, hf_cm_rep_e2eflowctl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3150             proto_tree_add_item(CM_header_tree, hf_cm_rep_rnrretrycount, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3151             proto_tree_add_item(CM_header_tree, hf_cm_rep_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3152             local_offset += 1;  /* skip reserved */
3153             proto_tree_add_item(CM_header_tree, hf_cm_rep_localcaguid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3154
3155             /* the following saves information about the conversation this packet defines,
3156                so there's no point in doing it more than once per packet */
3157             if(!pinfo->fd->flags.visited)
3158             {
3159                 /* get the previously saved context for this connection */
3160                 guint64 hash_key;
3161                 hash_key = MadData.transactionID;
3162                 ADD_ADDRESS_TO_HASH(hash_key, &pinfo->dst);
3163                 connection = g_hash_table_lookup(CM_context_table, &hash_key);
3164
3165                 /* if an appropriate connection was not found there's something wrong, but nothing we can
3166                    do about it here - so just skip saving the context */
3167                 if(connection)
3168                 {
3169                     address req_addr,
3170                             resp_addr;  /* we'll fill these in and pass them to conversation_new */
3171                     conversation_t *conv;
3172                     conversation_infiniband_data *proto_data = NULL;
3173
3174                     connection->resp_qp = remote_qpn;
3175
3176                     proto_data = se_alloc(sizeof(conversation_infiniband_data));
3177                     proto_data->service_id = connection->service_id;
3178
3179                     /* RC traffic never(?) includes a field indicating the source QPN, so
3180                        the destination host knows it only from previous context (a single
3181                        QPN on the host that is part of an RC can only receive traffic from
3182                        that RC). For this reason we do not register conversations with both
3183                        sides, but rather we register the same conversation twice - once for
3184                        each side of the Reliable Connection. */
3185
3186                     /* first register the conversation using the GIDs */
3187                     SET_ADDRESS(&req_addr, AT_IB, GID_SIZE, connection->req_gid);
3188                     SET_ADDRESS(&resp_addr, AT_IB, GID_SIZE, connection->resp_gid);
3189
3190                     conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr,
3191                                             PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2);
3192                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3193                     conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr,
3194                                             PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2);
3195                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3196
3197                     /* next, register the conversation using the LIDs */
3198                     SET_ADDRESS(&req_addr, AT_IB, sizeof(guint16), &(connection->req_lid));
3199                     SET_ADDRESS(&resp_addr, AT_IB, sizeof(guint16), &(connection->resp_lid));
3200
3201                     conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr,
3202                                             PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2);
3203                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3204                     conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr,
3205                                             PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2);
3206                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3207
3208                     g_hash_table_remove(CM_context_table, &hash_key);
3209                 }
3210             }
3211
3212             /* give a chance for subdissectors to get the private data */
3213             next_tvb = tvb_new_subset(tvb, local_offset, 196, -1);
3214             if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree) )
3215                 /* if none reported success, add this as raw "data" */
3216                 proto_tree_add_item(CM_header_tree, hf_cm_rep_privatedata, tvb, local_offset, 196, ENC_NA);
3217
3218             local_offset += 196;
3219             break;
3220         case ATTR_CM_RTU:
3221             proto_tree_add_item(CM_header_tree, hf_cm_rtu_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3222             proto_tree_add_item(CM_header_tree, hf_cm_rtu_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3223             /* currently only REQ/REP call subdissectors for the private data */
3224             proto_tree_add_item(CM_header_tree, hf_cm_rtu_privatedata, tvb, local_offset, 224, ENC_NA); local_offset += 224;
3225             break;
3226         case ATTR_CM_REJ:
3227             proto_tree_add_item(CM_header_tree, hf_cm_rej_local_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3228             proto_tree_add_item(CM_header_tree, hf_cm_rej_remote_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3229             proto_tree_add_item(CM_header_tree, hf_cm_rej_msg_rej, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3230             local_offset += 1;  /* skip reserved */
3231             proto_tree_add_item(CM_header_tree, hf_cm_rej_rej_info_len, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3232             local_offset += 1;  /* skip reserved */
3233             proto_tree_add_item(CM_header_tree, hf_cm_rej_reason, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3234             proto_tree_add_item(CM_header_tree, hf_cm_rej_add_rej_info, tvb, local_offset, 72, ENC_NA); local_offset += 72;
3235             /* currently only REQ/REP call subdissectors for the private data */
3236             proto_tree_add_item(CM_header_tree, hf_cm_rej_private_data, tvb, local_offset, 148, ENC_NA); local_offset += 148;
3237             break;
3238         default:
3239             proto_item_append_text(CM_header_item, " (Dissector Not Implemented)"); local_offset += MAD_DATA_SIZE;
3240             break;
3241     }
3242
3243     *offset = local_offset;
3244 }
3245
3246 /* Parse SNMP Tunneling
3247 * IN: parentTree to add the dissection to
3248 * IN: tvb - the data buffer from wireshark
3249 * IN/OUT: The current and updated offset */
3250 static void parse_SNMP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3251 {
3252     /* Parse the Common MAD Header */
3253     MAD_Data MadData;
3254     gint local_offset;
3255     proto_item *PERF_header_item = NULL;
3256
3257     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3258     {
3259         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3260         return;
3261     }
3262     local_offset = *offset;
3263
3264     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3265     proto_item_set_text(PERF_header_item, "%s", "SNMP - SNMP Tunneling MAD (Dissector Not Implemented)");
3266     *offset = local_offset;
3267 }
3268
3269 /* Parse Vendor Specific Management Packets
3270 * IN: parentTree to add the dissection to
3271 * IN: tvb - the data buffer from wireshark
3272 * IN/OUT: The current and updated offset */
3273 static void parse_VENDOR_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3274 {
3275     /* Parse the Common MAD Header */
3276     MAD_Data MadData;
3277     gint local_offset;
3278     proto_item *PERF_header_item = NULL;
3279
3280     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3281     {
3282         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3283         return;
3284     }
3285     local_offset = *offset;
3286
3287     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3288     proto_item_set_text(PERF_header_item, "%s", "VENDOR - Vendor Specific Management MAD (Dissector Not Implemented)");
3289     *offset = local_offset;
3290 }
3291
3292 /* Parse Application Specific Management Packets
3293 * IN: parentTree to add the dissection to
3294 * IN: tvb - the data buffer from wireshark
3295 * IN/OUT: The current and updated offset */
3296 static void parse_APPLICATION_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3297 {
3298     /* Parse the Common MAD Header */
3299     MAD_Data MadData;
3300     gint local_offset;
3301     proto_item *PERF_header_item = NULL;
3302
3303     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3304     {
3305         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3306         return;
3307     }
3308     local_offset = *offset;
3309     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3310     proto_item_set_text(PERF_header_item, "%s", "APP - Application Specific MAD (Dissector Not Implemented)");
3311     *offset = local_offset;
3312 }
3313
3314 /* Parse Reserved Management Packets.
3315
3316 * This is an !ERROR CONDITION!
3317 * It means that the Management Class value used was defined as a reserved value for furture use.
3318 * This method is here since we will want to report this information directly to the UI without blowing up Wireshark.
3319
3320 * IN: parentTree to add the dissection to
3321 * IN: tvb - the data buffer from wireshark
3322 * IN/OUT: The current and updated offset */
3323 static void parse_RESERVED_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3324 {
3325     /* Parse the Common MAD Header */
3326     MAD_Data MadData;
3327     gint local_offset;
3328     proto_item *PERF_header_item = NULL;
3329
3330     if(!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3331     {
3332         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3333         return;
3334     }
3335     local_offset = *offset;
3336     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 256, ENC_NA); local_offset += 256;
3337     proto_item_set_text(PERF_header_item, "%s", "RESERVED - Reserved MAD Type (Possible Device Error)");
3338     *offset = local_offset;
3339 }
3340
3341 /* Parse the common MAD Header
3342 * IN: parentTree to add the dissection to
3343 * IN: tvb - the data buffer from wireshark
3344 * IN/OUT: The current and updated offset
3345 * IN/OUT: MadData - the data from the MAD header */
3346 static gboolean parse_MAD_Common(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data* MadData)
3347 {
3348     gint local_offset = *offset;
3349     proto_tree *MAD_header_tree = NULL;
3350     proto_item *MAD_header_item = NULL;
3351
3352     if(MadData == NULL)
3353         return FALSE;
3354     if(!tvb_bytes_exist(tvb, *offset, 256))
3355         return FALSE;
3356
3357     /* Get the Management Class to decide between LID Routed and Direct Route */
3358     MadData->managementClass =      tvb_get_guint8(tvb, local_offset + 1);
3359     MadData->classVersion =         tvb_get_guint8(tvb, local_offset + 2);
3360     MadData->method =               tvb_get_guint8(tvb, local_offset + 3);
3361     MadData->status =               tvb_get_guint8(tvb, local_offset + 4);
3362     MadData->classSpecific =        tvb_get_ntohs(tvb, local_offset + 6);
3363     MadData->transactionID =        tvb_get_ntoh64(tvb, local_offset + 8);
3364     MadData->attributeID =          tvb_get_ntohs(tvb, local_offset + 16);
3365     MadData->attributeModifier =    tvb_get_ntohl(tvb, local_offset + 20);
3366     tvb_memcpy(tvb, MadData->data, local_offset + 24, MAD_DATA_SIZE);
3367
3368     /* Populate the Dissector Tree */
3369
3370     MAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_MAD, tvb, local_offset, 256, ENC_NA);
3371     proto_item_set_text(MAD_header_item, "%s", "MAD Header - Common Management Datagram");
3372     MAD_header_tree = proto_item_add_subtree(MAD_header_item, ett_mad);
3373
3374     proto_tree_add_item(MAD_header_tree, hf_infiniband_base_version,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3375     proto_tree_add_item(MAD_header_tree, hf_infiniband_mgmt_class,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3376     proto_tree_add_item(MAD_header_tree, hf_infiniband_class_version,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3377     proto_tree_add_item(MAD_header_tree, hf_infiniband_method,              tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3378     proto_tree_add_item(MAD_header_tree, hf_infiniband_status,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3379     proto_tree_add_item(MAD_header_tree, hf_infiniband_class_specific,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3380     proto_tree_add_item(MAD_header_tree, hf_infiniband_transaction_id,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
3381     proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_id,        tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3382     proto_tree_add_item(MAD_header_tree, hf_infiniband_reserved16,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3383     proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_modifier,  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3384     proto_tree_add_item(MAD_header_tree, hf_infiniband_data,                tvb, local_offset, MAD_DATA_SIZE, ENC_NA);
3385     *offset = local_offset; /* Move the offset to the start of the Data field - this will be where the other parsers start. */
3386
3387     return TRUE;
3388 }
3389
3390 /* Parse the RMPP (Reliable Multi-Packet Transaction Protocol
3391 * IN: parentTree to add the dissection to
3392 * IN: tvb - the data buffer from wireshark
3393 * IN/OUT: The current and updated offset */
3394 static gboolean parse_RMPP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3395 {
3396     gint local_offset = *offset;
3397     guint8 RMPP_Type = tvb_get_guint8(tvb, local_offset + 1);
3398     proto_tree *RMPP_header_tree = NULL;
3399     proto_item *RMPP_header_item = NULL;
3400
3401     RMPP_header_item = proto_tree_add_item(parentTree, hf_infiniband_RMPP, tvb, local_offset, 12, ENC_NA);
3402     proto_item_set_text(RMPP_header_item, "%s", val_to_str(RMPP_Type, RMPP_Packet_Types, "Reserved RMPP Type! (0x%02x)"));
3403     RMPP_header_tree = proto_item_add_subtree(RMPP_header_item, ett_rmpp);
3404
3405     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_version,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3406     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_type,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3407     proto_tree_add_item(RMPP_header_tree, hf_infiniband_r_resp_time,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3408     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_flags,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3409     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_status,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3410     switch(RMPP_Type)
3411     {
3412         case RMPP_ILLEGAL:
3413             proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data1,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3414             proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data2,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3415             break;
3416         case RMPP_DATA:
3417             proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3418             proto_tree_add_item(RMPP_header_tree, hf_infiniband_payload_length32,   tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3419             proto_tree_add_item(RMPP_header_tree, hf_infiniband_transferred_data,   tvb, local_offset, 220, ENC_NA);
3420             break;
3421         case RMPP_ACK:
3422             proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3423             proto_tree_add_item(RMPP_header_tree, hf_infiniband_new_window_last,    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
3424             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved220,        tvb, local_offset, 220, ENC_NA);
3425             break;
3426         case RMPP_STOP:
3427         case RMPP_ABORT:
3428             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32,                     tvb, local_offset, 4, FALSE); local_offset+=4;
3429             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32,                     tvb, local_offset, 4, FALSE); local_offset+=4;
3430             proto_tree_add_item(RMPP_header_tree, hf_infiniband_optional_extended_error_data,   tvb, local_offset, 220, ENC_NA);
3431             break;
3432         default:
3433             break;
3434     }
3435     *offset = local_offset;
3436     return TRUE;
3437 }
3438
3439 /* Parse the Method from the MAD Common Header.
3440 * Simply used to generate the identifier.
3441 * IN: SubMItem - the item to append the method label to.
3442 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3443 * IN: pinfo - packet info from wireshark. */
3444 static void label_SUBM_Method(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo)
3445 {
3446     const char *label = val_to_str(MadHeader->method, SUBM_Methods, "(Unknown SubManagement Method!)");
3447
3448     proto_item_append_text(SubMItem, "%s", label);
3449     col_append_str(pinfo->cinfo, COL_INFO, label);
3450 }
3451
3452 /* Parse the SA Method from the MAD Common Header.
3453 * Simply used to generate the identifier.
3454 * IN: SubAItem - the item to append the method label to.
3455 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3456 * IN: pinfo - packet info from wireshark. */
3457 static void label_SUBA_Method(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo)
3458 {
3459     const char *label = val_to_str(MadHeader->method, SUBA_Methods, "(Unknown SubAdministration Method!)");
3460
3461     proto_item_append_text(SubAItem, "%s", label);
3462     col_append_str(pinfo->cinfo, COL_INFO, label);
3463 }
3464
3465 /* Parse the Attribute from the MAD Common Header
3466 * Simply used to generate the identifier.
3467 * IN: SubMItem - the item to append the Attribute label to.
3468 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3469 * IN: pinfo - packet info from wireshark. */
3470 static void label_SUBM_Attribute(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo)
3471 {
3472     const char *label = val_to_str(MadHeader->attributeID, SUBM_Attributes, "(Unknown SubManagement Attribute!)");
3473
3474     proto_item_append_text(SubMItem, "%s", &label[11]);
3475     col_append_str(pinfo->cinfo, COL_INFO, &label[11]);
3476 }
3477
3478 /* Parse the SA Attribute from the MAD Common Header
3479 * Simply used to generate the identifier.
3480 * IN: SubAItem - the item to append the Attribute label to.
3481 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3482 * IN: pinfo - packet info from wireshark. */
3483 static void label_SUBA_Attribute(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo)
3484 {
3485     const char *label = val_to_str(MadHeader->attributeID, SUBA_Attributes, "(Unknown SubAdministration Attribute!)");
3486
3487     proto_item_append_text(SubAItem, "%s", &label[11]);
3488     col_append_str(pinfo->cinfo, COL_INFO, &label[11]);
3489 }
3490
3491 /* Parse the attribute from a Subnet Management Packet.
3492 * IN: Parent Tree to add the item to in the dissection tree
3493 * IN: tvbuff, offset - the data and where it is.
3494 * IN: MAD_Data the data from the Common MAD Header that provides the information we need */
3495 static gboolean parse_SUBM_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader)
3496 {
3497     guint16 attributeID = MadHeader->attributeID;
3498     proto_tree *SUBM_Attribute_header_tree = NULL;
3499     proto_item *SUBM_Attribute_header_item = NULL;
3500
3501     SUBM_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, *offset, 64, ENC_NA);
3502     proto_item_set_text(SUBM_Attribute_header_item, "%s", val_to_str(attributeID, SUBM_Attributes, "Unknown Attribute Type! (0x%02x)"));
3503     SUBM_Attribute_header_tree = proto_item_add_subtree(SUBM_Attribute_header_item, ett_subm_attribute);
3504
3505
3506     switch(attributeID)
3507     {
3508         case 0x0002:
3509             parse_NoticesAndTraps(SUBM_Attribute_header_tree , tvb, offset);
3510             break;
3511         case 0x0010:
3512              parse_NodeDescription(SUBM_Attribute_header_tree , tvb, offset);
3513             break;
3514         case 0x0011:
3515             parse_NodeInfo(SUBM_Attribute_header_tree , tvb, offset);
3516             break;
3517         case 0x0012:
3518             parse_SwitchInfo(SUBM_Attribute_header_tree , tvb, offset);
3519             break;
3520         case 0x0014:
3521             parse_GUIDInfo(SUBM_Attribute_header_tree , tvb, offset);
3522             break;
3523         case 0x0015:
3524             parse_PortInfo(SUBM_Attribute_header_tree , tvb, offset);
3525             break;
3526         case 0x0016:
3527             parse_P_KeyTable(SUBM_Attribute_header_tree , tvb, offset);
3528             break;
3529         case 0x0017:
3530             parse_SLtoVLMappingTable(SUBM_Attribute_header_tree , tvb, offset);
3531             break;
3532         case 0x0018:
3533             parse_VLArbitrationTable(SUBM_Attribute_header_tree , tvb, offset);
3534             break;
3535         case 0x0019:
3536             parse_LinearForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3537             break;
3538         case 0x001A:
3539             parse_RandomForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3540             break;
3541         case 0x001B:
3542             parse_MulticastForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3543             break;
3544         case 0x001C:
3545             parse_SMInfo(SUBM_Attribute_header_tree , tvb, offset);
3546             break;
3547         case 0x0020:
3548             parse_VendorDiag(SUBM_Attribute_header_tree , tvb, offset);
3549             break;
3550         case 0x0030:
3551             parse_LedInfo(SUBM_Attribute_header_tree , tvb, offset);
3552             break;
3553         case 0x0031:
3554             parse_LinkSpeedWidthPairsTable(SUBM_Attribute_header_tree , tvb, offset);
3555             break;
3556         default:
3557             break;
3558     }
3559
3560
3561     *offset += 64;
3562     return TRUE;
3563
3564 }
3565 /* Parse the attribute from a Subnet Administration Packet.
3566 * IN: Parent Tree to add the item to in the dissection tree
3567 * IN: tvbuff, offset - the data and where it is.
3568 * IN: MAD_Data the data from the Common MAD Header that provides the information we need */
3569 static gboolean parse_SUBA_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader)
3570 {
3571     guint16 attributeID = MadHeader->attributeID;
3572     proto_tree *SUBA_Attribute_header_tree = NULL;
3573     proto_item *SUBA_Attribute_header_item = NULL;
3574
3575     SUBA_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, *offset, 200, ENC_NA);
3576     proto_item_set_text(SUBA_Attribute_header_item, "%s", val_to_str(attributeID, SUBA_Attributes, "Unknown Attribute Type! (0x%02x)"));
3577     SUBA_Attribute_header_tree = proto_item_add_subtree(SUBA_Attribute_header_item, ett_suba_attribute);
3578
3579     /* Skim off the RID fields should they be present */
3580     parse_RID(SUBA_Attribute_header_tree, tvb, offset, MadHeader);
3581
3582     /* Parse the rest of the attributes */
3583     switch(MadHeader->attributeID)
3584     {
3585         case 0x0001: /* (ClassPortInfo) */
3586             parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset);
3587             break;
3588         case 0x0002: /* (Notice) */
3589             parse_NoticesAndTraps(SUBA_Attribute_header_tree, tvb, offset);
3590             break;
3591         case 0x0003: /* (InformInfo) */
3592             parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset);
3593             break;
3594         case 0x0011: /* (NodeRecord) */
3595             parse_NodeInfo(SUBA_Attribute_header_tree, tvb, offset);
3596             *offset += 40;
3597             parse_NodeDescription(SUBA_Attribute_header_tree, tvb, offset);
3598             break;
3599         case 0x0012: /* (PortInfoRecord) */
3600             parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset);
3601             break;
3602         case 0x0013: /* (SLtoVLMappingTableRecord) */
3603             parse_SLtoVLMappingTable(SUBA_Attribute_header_tree, tvb, offset);
3604             break;
3605         case 0x0014: /* (SwitchInfoRecord) */
3606             parse_SwitchInfo(SUBA_Attribute_header_tree, tvb, offset);
3607             break;
3608         case 0x0015: /*(LinearForwardingTableRecord) */
3609             parse_LinearForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3610             break;
3611         case 0x0016: /* (RandomForwardingTableRecord) */
3612             parse_RandomForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3613             break;
3614         case 0x0017: /* (MulticastForwardingTableRecord) */
3615             parse_MulticastForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3616             break;
3617         case 0x0018: /* (SMInfoRecord) */
3618             parse_SMInfo(SUBA_Attribute_header_tree, tvb, offset);
3619             break;
3620         case 0x0019: /* (LinkSpeedWidthPairsTableRecord) */
3621             parse_LinkSpeedWidthPairsTable(SUBA_Attribute_header_tree, tvb, offset);
3622             break;
3623         case 0x00F3: /*(InformInfoRecord) */
3624             parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset);
3625             break;
3626         case 0x0020: /* (LinkRecord) */
3627             parse_LinkRecord(SUBA_Attribute_header_tree, tvb, offset);
3628             break;
3629         case 0x0030: /* (GuidInforecord) */
3630             parse_GUIDInfo(SUBA_Attribute_header_tree, tvb, offset);
3631             break;
3632         case 0x0031: /*(ServiceRecord) */
3633             parse_ServiceRecord(SUBA_Attribute_header_tree, tvb, offset);
3634             break;
3635         case 0x0033: /* (P_KeyTableRecord) */
3636             parse_P_KeyTable(SUBA_Attribute_header_tree, tvb, offset);
3637             break;
3638         case 0x0035: /* (PathRecord) */
3639             parse_PathRecord(SUBA_Attribute_header_tree, tvb, offset);
3640             break;
3641         case 0x0036: /* (VLArbitrationTableRecord) */
3642             parse_VLArbitrationTable(SUBA_Attribute_header_tree, tvb, offset);
3643             break;
3644         case 0x0038: /* (MCMemberRecord) */
3645             parse_MCMemberRecord(SUBA_Attribute_header_tree, tvb, offset);
3646             break;
3647         case 0x0039: /* (TraceRecord) */
3648             parse_TraceRecord(SUBA_Attribute_header_tree, tvb, offset);
3649             break;
3650         case 0x003A: /* (MultiPathRecord) */
3651             parse_MultiPathRecord(SUBA_Attribute_header_tree, tvb, offset);
3652             break;
3653         case 0x003B: /* (ServiceAssociationRecord) */
3654             parse_ServiceAssociationRecord(SUBA_Attribute_header_tree, tvb, offset);
3655             break;
3656         default: /* (Unknown SubAdministration Attribute!) */
3657             /* We've already labeled as unknown in item construction */
3658             break;
3659     }
3660
3661     *offset += 200;
3662     return TRUE;
3663 }
3664
3665 /* Subnet Management Attribute Parsing Methods.
3666 *  Also Parsing for Attributes common to both SM/SA.
3667 * The Subnet Admin Parsing methods will call some of these methods when an attribute is present within an SA MAD
3668 */
3669
3670
3671 /* Parse NoticeDataDetails Attribute Field
3672 * IN:   parentTree - The tree to add the dissection to
3673 *       tvb - The tvbbuff of packet data
3674 *       offset - The offset in TVB where the attribute begins
3675 *       trapNumber - The Trap ID of the Trap Data being Dissected  */
3676
3677 static void parse_NoticeDataDetails(proto_tree* parentTree, tvbuff_t* tvb, gint *offset, guint16 trapNumber)
3678 {
3679     gint local_offset = *offset;
3680     proto_tree *DataDetails_header_tree = NULL;
3681     proto_item *DataDetails_header_item = NULL;
3682
3683     if(!parentTree)
3684         return;
3685
3686     DataDetails_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 54, ENC_NA);
3687     DataDetails_header_tree = proto_item_add_subtree(DataDetails_header_item, ett_datadetails);
3688
3689
3690     switch(trapNumber)
3691     {
3692         case 64:
3693             proto_item_set_text(DataDetails_header_item, "%s", "Trap 64 DataDetails");
3694             local_offset +=6;
3695             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3696         break;
3697         case 65:
3698             proto_item_set_text(DataDetails_header_item, "%s", "Trap 65 DataDetails");
3699             local_offset +=6;
3700             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3701         break;
3702         case 66:
3703             proto_item_set_text(DataDetails_header_item, "%s", "Trap 66 DataDetails");
3704             local_offset +=6;
3705             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3706         break;
3707         case 67:
3708             proto_item_set_text(DataDetails_header_item, "%s", "Trap 67 DataDetails");
3709             local_offset +=6;
3710             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3711         break;
3712         case 68:
3713             proto_item_set_text(DataDetails_header_item, "%s", "Trap 68 DataDetails");
3714             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK,          tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset+=8;
3715             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3716         break;
3717         case 69:
3718             proto_item_set_text(DataDetails_header_item, "%s", "Trap 69 DataDetails");
3719             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK,          tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset+=8;
3720             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3721         break;
3722         case 128:
3723             proto_item_set_text(DataDetails_header_item, "%s", "Trap 128 DataDetails");
3724             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3725         break;
3726         case 129:
3727             proto_item_set_text(DataDetails_header_item, "%s", "Trap 129 DataDetails");
3728             local_offset += 2;
3729             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3730             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3731         break;
3732         case 130:
3733             proto_item_set_text(DataDetails_header_item, "%s", "Trap 130 DataDetails");
3734             local_offset += 2;
3735             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3736             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3737         break;
3738         case 131:
3739             proto_item_set_text(DataDetails_header_item, "%s", "Trap 131 DataDetails");
3740             local_offset += 2;
3741             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3742             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3743         break;
3744         case 144:
3745             proto_item_set_text(DataDetails_header_item, "%s", "Trap 144 DataDetails");
3746             local_offset +=2;
3747             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3748             local_offset +=1;
3749             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_OtherLocalChanges,      tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3750             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_CAPABILITYMASK,     tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset+=4;
3751             local_offset +=1;
3752             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkSpeecEnabledChange,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3753             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkWidthEnabledChange,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3754             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_NodeDescriptionChange,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
3755         break;
3756         case 145:
3757             proto_item_set_text(DataDetails_header_item, "%s", "Trap 145 DataDetails");
3758             local_offset +=2;
3759             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3760             local_offset +=2;
3761             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SYSTEMIMAGEGUID,        tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset+=8;
3762         break;
3763         case 256:
3764             proto_item_set_text(DataDetails_header_item, "%s", "Trap 256 DataDetails");
3765             local_offset +=2;
3766             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,            tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3767             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRSLID,             tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3768             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_METHOD,             tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3769             local_offset +=1;
3770             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEID,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3771             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEMODIFIER,  tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset+=4;
3772             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_MKEY,               tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset+=8;
3773             local_offset +=1;
3774             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNotice,           tvb, local_offset, 1, ENC_BIG_ENDIAN);
3775             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRPathTruncated,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3776             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRHopCount,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3777             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNoticeReturnPath, tvb, local_offset, 30, ENC_NA);  local_offset+=30;
3778         break;
3779         case 257:
3780             proto_item_set_text(DataDetails_header_item, "%s", "Trap 257 DataDetails");
3781             local_offset+=2;
3782             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3783             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3784             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY,        tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset+=4;
3785             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3786             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3787             local_offset +=1;
3788             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3789             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3790             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3791         break;
3792         case 258:
3793             proto_item_set_text(DataDetails_header_item, "%s", "Trap 258 DataDetails");
3794             local_offset+=2;
3795             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3796             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3797             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY,        tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset+=4;
3798             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset +=1;
3799             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3800             local_offset +=1;
3801             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3802             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3803             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3804         break;
3805         case 259:
3806             proto_item_set_text(DataDetails_header_item, "%s", "Trap 259 DataDetails");
3807             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DataValid,  tvb, local_offset, 2, ENC_NA);  local_offset+=2;
3808             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3809             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3810             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PKEY,       tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset+=2;
3811             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3812             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3813             local_offset +=1;
3814             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset+=3;
3815             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3816             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset+=16;
3817             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SWLIDADDR,  tvb, local_offset, 2, ENC_NA);  local_offset+=2;
3818             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,     tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset+=1;
3819         break;
3820         default:
3821             proto_item_set_text(DataDetails_header_item, "%s", "Vendor Specific Subnet Management Trap"); local_offset +=54;
3822             break;
3823     }
3824
3825 }
3826
3827 /* Parse NoticesAndTraps Attribute
3828 * IN:   parentTree - The tree to add the dissection to
3829 *       tvb - The tvbbuff of packet data
3830 *       offset - The offset in TVB where the attribute begins
3831 *       MadHeader - The common MAD header of the current SMP/SMA  */
3832 static void parse_NoticesAndTraps(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3833 {
3834     gint local_offset = *offset;
3835     proto_tree *NoticesAndTraps_header_tree = NULL;
3836     proto_item *NoticesAndTraps_header_item = NULL;
3837     guint16 trapNumber = tvb_get_ntohs(tvb, local_offset + 4);
3838
3839     if(!parentTree)
3840         return;
3841
3842     NoticesAndTraps_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
3843     proto_item_set_text(NoticesAndTraps_header_item, "%s", val_to_str(trapNumber, Trap_Description, "Unknown or Vendor Specific Trap Number! (0x%02x)"));
3844     NoticesAndTraps_header_tree = proto_item_add_subtree(NoticesAndTraps_header_item, ett_noticestraps);
3845
3846     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IsGeneric,                tvb, local_offset, 1, ENC_BIG_ENDIAN);
3847     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_Type,                     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
3848     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ProducerTypeVendorID,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
3849     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_TrapNumberDeviceID,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3850     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerLID,                tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3851     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeToggle,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
3852     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeCount,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
3853
3854     parse_NoticeDataDetails(NoticesAndTraps_header_tree, tvb, &local_offset, trapNumber);
3855     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_DataDetails,              tvb, local_offset, 54, ENC_NA); local_offset+=54;
3856
3857     /* Only Defined For GMPs not SMPs which is not part of this dissector phase
3858     *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerGID,               tvb, local_offset, 16, ENC_NA); local_offset+=16;
3859     *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ClassTrapSpecificData,   tvb, local_offset, 1, ENC_NA); local_offset+=1; */
3860
3861 }
3862
3863 /* Parse NodeDescription Attribute
3864 * IN:   parentTree - The tree to add the dissection to
3865 *       tvb - The tvbbuff of packet data
3866 *       offset - The offset in TVB where the attribute begins
3867 *       MadHeader - The common MAD header of the current SMP/SMA  */
3868 static void parse_NodeDescription(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3869 {
3870     gint local_offset = *offset;
3871     proto_tree *NodeDescription_header_tree = NULL;
3872
3873     if(!parentTree)
3874         return;
3875
3876     NodeDescription_header_tree = parentTree;
3877     proto_tree_add_item(NodeDescription_header_tree, hf_infiniband_NodeDescription_NodeString,  tvb, local_offset, 64, ENC_ASCII|ENC_NA);
3878 }
3879
3880 /* Parse NodeInfo Attribute
3881 * IN:   parentTree - The tree to add the dissection to
3882 *       tvb - The tvbbuff of packet data
3883 *       offset - The offset in TVB where the attribute begins
3884 *       MadHeader - The common MAD header of the current SMP/SMA  */
3885 static void parse_NodeInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3886 {
3887     gint local_offset = *offset;
3888     proto_tree *NodeInfo_header_tree = NULL;
3889
3890     if(!parentTree)
3891         return;
3892
3893     NodeInfo_header_tree = parentTree;
3894
3895     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_BaseVersion,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3896     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_ClassVersion,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3897     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeType,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3898     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NumPorts,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3899     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_SystemImageGUID,   tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3900     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeGUID,          tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3901     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PortGUID,          tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3902     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PartitionCap,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3903     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_DeviceID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3904     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_Revision,          tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset +=4;
3905     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_LocalPortNum,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3906     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_VendorID,          tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset +=3;
3907
3908 }
3909
3910 /* Parse SwitchInfo Attribute
3911 * IN:   parentTree - The tree to add the dissection to
3912 *       tvb - The tvbbuff of packet data
3913 *       offset - The offset in TVB where the attribute begins
3914 *       MadHeader - The common MAD header of the current SMP/SMA  */
3915 static void parse_SwitchInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3916 {
3917     gint local_offset = *offset;
3918     proto_tree *SwitchInfo_header_tree = NULL;
3919
3920     if(!parentTree)
3921         return;
3922
3923     SwitchInfo_header_tree = parentTree;
3924
3925     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBCap,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3926     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_RandomFDBCap,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3927     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_MulticastFDBCap,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3928     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBTop,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3929     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultPort,                       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3930     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3931     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3932     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LifeTimeValue,                     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3933     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PortStateChange,                   tvb, local_offset, 1, ENC_BIG_ENDIAN);
3934     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3935     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LIDsPerPort,                       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3936     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PartitionEnforcementCap,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3937     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_InboundEnforcementCap,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
3938     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OutboundEnforcementCap,            tvb, local_offset, 1, ENC_BIG_ENDIAN);
3939     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawInboundCap,               tvb, local_offset, 1, ENC_BIG_ENDIAN);
3940     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawOutboundCap,              tvb, local_offset, 1, ENC_BIG_ENDIAN);
3941     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_EnhancedPortZero,                  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
3942 }
3943
3944 /* Parse GUIDInfo Attribute
3945 * IN:   parentTree - The tree to add the dissection to
3946 *       tvb - The tvbbuff of packet data
3947 *       offset - The offset in TVB where the attribute begins
3948 *       MadHeader - The common MAD header of the current SMP/SMA  */
3949 static void parse_GUIDInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3950 {
3951     gint local_offset = *offset;
3952     proto_tree *GUIDInfo_header_tree = NULL;
3953     proto_item *tempItemLow = NULL;
3954     gint i = 0;
3955
3956     if(!parentTree)
3957         return;
3958
3959     GUIDInfo_header_tree = parentTree;
3960
3961     for(i = 0; i < 8; i++)
3962     {
3963         proto_tree_add_item(GUIDInfo_header_tree, hf_infiniband_GUIDInfo_GUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3964         proto_item_append_text(tempItemLow, "(%u)", i);
3965     }
3966
3967 }
3968
3969 /* Parse PortInfo Attribute
3970 * IN:   parentTree - The tree to add the dissection to
3971 *       tvb - The tvbbuff of packet data
3972 *       offset - The offset in TVB where the attribute begins
3973 *       MadHeader - The common MAD header of the current SMP/SMA  */
3974 static void parse_PortInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3975 {
3976     gint local_offset = *offset;
3977     proto_tree *PortInfo_header_tree = NULL;
3978     proto_tree *PortInfo_CapabilityMask_tree = NULL;
3979     proto_item *PortInfo_CapabilityMask_item = NULL;
3980     proto_item *temp_item = NULL;
3981     guint16 temp_val = 0;
3982
3983     if(!parentTree)
3984         return;
3985
3986     PortInfo_header_tree = parentTree;
3987
3988     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_Key,                 tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3989     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GidPrefix,             tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
3990     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3991     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMLID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
3992
3993     /* Capability Mask Flags */
3994     PortInfo_CapabilityMask_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_CapabilityMask,     tvb, local_offset, 4, ENC_BIG_ENDIAN);
3995     PortInfo_CapabilityMask_tree = proto_item_add_subtree(PortInfo_CapabilityMask_item, ett_portinfo_capmask);
3996
3997     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SM,                             tvb, local_offset, 4, ENC_BIG_ENDIAN);
3998     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_NoticeSupported,                tvb, local_offset, 4, ENC_BIG_ENDIAN);
3999     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_TrapSupported,                  tvb, local_offset, 4, ENC_BIG_ENDIAN);
4000     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported,            tvb, local_offset, 4, ENC_BIG_ENDIAN);
4001     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
4002     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported,             tvb, local_offset, 4, ENC_BIG_ENDIAN);
4003     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM,                      tvb, local_offset, 4, ENC_BIG_ENDIAN);
4004     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM,                      tvb, local_offset, 4, ENC_BIG_ENDIAN);
4005     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported,               tvb, local_offset, 4, ENC_BIG_ENDIAN);
4006     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SMdisabled,                     tvb, local_offset, 4, ENC_BIG_ENDIAN);
4007     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported,       tvb, local_offset, 4, ENC_BIG_ENDIAN);
4008     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
4009     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported,      tvb, local_offset, 4, ENC_BIG_ENDIAN);
4010     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported,                 tvb, local_offset, 4, ENC_BIG_ENDIAN);
4011     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ReinitSupported,                tvb, local_offset, 4, ENC_BIG_ENDIAN);
4012     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported,      tvb, local_offset, 4, ENC_BIG_ENDIAN);
4013     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported,           tvb, local_offset, 4, ENC_BIG_ENDIAN);
4014     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported,              tvb, local_offset, 4, ENC_BIG_ENDIAN);
4015     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
4016     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported,        tvb, local_offset, 4, ENC_BIG_ENDIAN);
4017     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
4018     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
4019     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported,   tvb, local_offset, 4, ENC_BIG_ENDIAN);
4020     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
4021     local_offset+=4;
4022     /* End Capability Mask Flags */
4023
4024     /* Diag Code */
4025     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_DiagCode,              tvb, local_offset, 2, ENC_BIG_ENDIAN);
4026     temp_val = tvb_get_ntohs(tvb, local_offset);
4027
4028     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, DiagCode, "Reserved DiagCode! Possible Error"));
4029     local_offset +=2;
4030     /* End Diag Code */
4031
4032     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyLeasePeriod,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4033     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPortNum,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4034
4035     /* LinkWidthEnabled */
4036     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthEnabled,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4037     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4038
4039     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkWidthEnabled, "Reserved LinkWidthEnabled Value! Possible Error"));
4040     local_offset +=1;
4041     /* End LinkWidthEnabled */
4042
4043     /* LinkWidthSupported */
4044     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthSupported,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4045     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4046
4047     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkWidthSupported, "Reserved LinkWidthSupported Value! Possible Error"));
4048     local_offset +=1;
4049     /* End LinkWidthSupported */
4050
4051     /* LinkWidthActive */
4052     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthActive,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
4053     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4054
4055     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkWidthActive, "Reserved LinkWidthActive Value! Possible Error"));
4056     local_offset +=1;
4057     /* End LinkWidthActive */
4058
4059     /* LinkSpeedSupported */
4060     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedSupported,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4061     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4062
4063     /* 4 bit values = mask and shift */
4064     temp_val = temp_val & 0x00F0;
4065     temp_val = temp_val >> 4;
4066
4067     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkSpeedSupported, "Reserved LinkWidthSupported Value! Possible Error"));
4068     /* End LinkSpeedSupported */
4069
4070     /* PortState */
4071     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortState,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
4072     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4073
4074     /* 4 bit values = mask and shift */
4075     temp_val = temp_val & 0x000F;
4076     /*temp_val = temp_val >> 4 */
4077
4078     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, PortState, "Reserved PortState Value! Possible Error"));
4079     local_offset +=1;
4080     /* End PortState */
4081
4082     /* PortPhysicalState */
4083     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortPhysicalState,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
4084     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4085
4086     /* 4 bit values = mask and shift */
4087     temp_val = temp_val & 0x00F0;
4088     temp_val = temp_val >> 4;
4089
4090     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, PortPhysicalState, "Reserved PortPhysicalState Value! Possible Error"));
4091     /* End PortPhysicalState */
4092
4093     /* LinkDownDefaultState */
4094     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkDownDefaultState,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4095     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4096
4097     /* 4 bit values = mask and shift */
4098     temp_val = temp_val & 0x000F;
4099     /*temp_val = temp_val >> 4 */
4100
4101     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkDownDefaultState, "Reserved LinkDownDefaultState Value! Possible Error"));
4102     local_offset +=1;
4103     /* End LinkDownDefaultState */
4104
4105     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyProtectBits,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4106     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LMC,                   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4107
4108     /* LinkSpeedActive */
4109     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedActive,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
4110     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4111
4112     /* 4 bit values = mask and shift */
4113     temp_val = temp_val & 0x00F0;
4114     temp_val = temp_val >> 4;
4115
4116     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkSpeedActive, "Reserved LinkSpeedActive Value! Possible Error"));
4117     /* End LinkSpeedActive */
4118
4119     /* LinkSpeedEnabled */
4120     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedEnabled,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4121     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4122
4123     /* 4 bit values = mask and shift */
4124     temp_val = temp_val & 0x000F;
4125     /*temp_val = temp_val >> 4 */
4126
4127     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, LinkSpeedEnabled, "Reserved LinkSpeedEnabled Value! Possible Error"));
4128     local_offset +=1;
4129     /* End LinkSpeedEnabled */
4130
4131     /* NeighborMTU */
4132     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_NeighborMTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN);
4133     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4134
4135     /* 4 bit values = mask and shift */
4136     temp_val = temp_val & 0x00F0;
4137     temp_val = temp_val >> 4;
4138
4139     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, NeighborMTU, "Reserved NeighborMTU Value! Possible Error"));
4140
4141     /* End NeighborMTU */
4142
4143     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMSL,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4144
4145     /* VLCap */
4146     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLCap,                 tvb, local_offset, 1, ENC_BIG_ENDIAN);
4147     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4148
4149     /* 4 bit values = mask and shift */
4150     temp_val = temp_val & 0x00F0;
4151     temp_val = temp_val >> 4;
4152
4153     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, VLCap, "Reserved VLCap Value! Possible Error"));
4154
4155     /* End VLCap */
4156
4157     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitType,              tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4158     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLHighLimit,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4159     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationHighCap,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4160     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationLowCap,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4161     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitTypeReply,         tvb, local_offset, 1, ENC_BIG_ENDIAN);
4162
4163     /* MTUCap */
4164     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MTUCap,                tvb, local_offset, 1, ENC_BIG_ENDIAN);
4165     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4166
4167     /* 4 bit values = mask and shift */
4168     temp_val = temp_val & 0x000F;
4169     /*temp_val = temp_val >> 4 */
4170
4171     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, MTUCap, "Reserved MTUCap Value! Possible Error"));
4172     local_offset +=1;
4173     /* End MTUCap */
4174
4175     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLStallCount,          tvb, local_offset, 1, ENC_BIG_ENDIAN);
4176     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_HOQLife,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4177
4178     /* OperationalVLs */
4179     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OperationalVLs,        tvb, local_offset, 1, ENC_BIG_ENDIAN);
4180     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4181
4182     /* 4 bit values = mask and shift */
4183     temp_val = temp_val & 0x00F0;
4184     temp_val = temp_val >> 4;
4185
4186     proto_item_append_text(temp_item, ", %s", val_to_str(temp_val, OperationalVLs, "Reserved OperationalVLs Value! Possible Error"));
4187     /* End OperationalVLs */
4188
4189     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementInbound,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
4190     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementOutbound,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4191     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawInbound,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4192     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawOutbound,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4193     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4194     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_P_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4195     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_Q_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4196     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GUIDCap,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4197     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_ClientReregister,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4198     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_SubnetTimeOut,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4199     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_RespTimeValue,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4200     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPhyErrors,        tvb, local_offset, 1, ENC_BIG_ENDIAN);
4201     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OverrunErrors,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4202     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MaxCreditHint,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=3; /* 2 + 1 Reserved */
4203     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkRoundTripLatency,  tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset +=3;
4204 }
4205
4206 /* Parse P_KeyTable Attribute
4207 * IN:   parentTree - The tree to add the dissection to
4208 *       tvb - The tvbbuff of packet data
4209 *       offset - The offset in TVB where the attribute begins
4210 *       MadHeader - The common MAD header of the current SMP/SMA  */
4211 static void parse_P_KeyTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4212 {
4213     gint local_offset = *offset;
4214     gint i = 0;
4215     proto_tree *P_KeyTable_header_tree = NULL;
4216     proto_item *P_KeyTable_header_item = NULL;
4217     proto_item *tempItemLow = NULL;
4218     proto_item *tempItemHigh = NULL;
4219
4220     if(!parentTree)
4221         return;
4222
4223     P_KeyTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_P_KeyTable_P_KeyTableBlock, tvb, local_offset, 64, ENC_NA);
4224     proto_item_set_text(P_KeyTable_header_item, "%s", "P_KeyTable");
4225     P_KeyTable_header_tree = proto_item_add_subtree(P_KeyTable_header_item, ett_pkeytable);
4226
4227     for(i = 0; i < 32; i++)
4228     {
4229         tempItemLow = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_MembershipType,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4230         tempItemHigh = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_P_KeyBase,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4231         proto_item_append_text(tempItemLow, "(%u)", i);
4232         proto_item_append_text(tempItemHigh,"(%u)", i+1);
4233     }
4234 }
4235
4236 /* Parse SLtoVLMappingTable Attribute
4237 * IN:   parentTree - The tree to add the dissection to
4238 *       tvb - The tvbbuff of packet data
4239 *       offset - The offset in TVB where the attribute begins
4240 *       MadHeader - The common MAD header of the current SMP/SMA  */
4241 static void parse_SLtoVLMappingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4242 {
4243     gint local_offset = *offset;
4244     proto_tree *SLtoVLMappingTable_header_tree = NULL;
4245     proto_item *SLtoVLMappingTable_header_item = NULL;
4246     proto_item *tempItemLow = NULL;
4247     proto_item *tempItemHigh = NULL;
4248     gint i = 0;
4249
4250     if(!parentTree)
4251         return;
4252
4253     SLtoVLMappingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4254     proto_item_set_text(SLtoVLMappingTable_header_item, "%s", "SLtoVLMappingTable");
4255     SLtoVLMappingTable_header_tree = proto_item_add_subtree(SLtoVLMappingTable_header_item, ett_sltovlmapping);
4256
4257     for(i = 0; i < 8; i++)
4258     {
4259         tempItemLow = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4260         tempItemHigh = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4261         proto_item_append_text(tempItemLow, "(%u)", i);
4262         proto_item_append_text(tempItemHigh,"(%u)", i+1);
4263     }
4264 }
4265
4266 /* Parse VLArbitrationTable Attribute
4267 * IN:   parentTree - The tree to add the dissection to
4268 *       tvb - The tvbbuff of packet data
4269 *       offset - The offset in TVB where the attribute begins
4270 *       MadHeader - The common MAD header of the current SMP/SMA  */
4271 static void parse_VLArbitrationTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4272 {
4273     gint local_offset = *offset;
4274     gint i = 0;
4275     proto_tree *VLArbitrationTable_header_tree = NULL;
4276     proto_item *VLArbitrationTable_header_item = NULL;
4277     proto_item *tempItemLow = NULL;
4278     proto_item *tempItemHigh = NULL;
4279
4280     if(!parentTree)
4281         return;
4282
4283     VLArbitrationTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4284     proto_item_set_text(VLArbitrationTable_header_item, "%s", "VLArbitrationTable");
4285     VLArbitrationTable_header_tree = proto_item_add_subtree(VLArbitrationTable_header_item, ett_vlarbitrationtable);
4286
4287     for(i = 0; i < 32; i++)
4288     {
4289         tempItemLow = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_VL,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4290         tempItemHigh = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_Weight, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4291         proto_item_append_text(tempItemLow, "(%u)", i);
4292         proto_item_append_text(tempItemHigh,"(%u)", i);
4293     }
4294 }
4295
4296 /* Parse LinearForwardingTable Attribute
4297 * IN:   parentTree - The tree to add the dissection to
4298 *       tvb - The tvbbuff of packet data
4299 *       offset - The offset in TVB where the attribute begins
4300 *       MadHeader - The common MAD header of the current SMP/SMA  */
4301 static void parse_LinearForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4302 {
4303     gint i = 0;
4304     gint local_offset = *offset;
4305     proto_tree *LinearForwardingTable_header_tree = NULL;
4306     proto_item *LinearForwardingTable_header_item = NULL;
4307     proto_item *tempItemLow = NULL;
4308
4309     if(!parentTree)
4310         return;
4311
4312     LinearForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4313     proto_item_set_text(LinearForwardingTable_header_item, "%s", "LinearForwardingTable");
4314     LinearForwardingTable_header_tree = proto_item_add_subtree(LinearForwardingTable_header_item, ett_linearforwardingtable);
4315
4316     for(i = 0; i < 64; i++)
4317     {
4318         tempItemLow = proto_tree_add_item(LinearForwardingTable_header_tree, hf_infiniband_LinearForwardingTable_Port, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4319         proto_item_append_text(tempItemLow, "(%u)", i);
4320     }
4321 }
4322
4323 /* Parse RandomForwardingTable Attribute
4324 * IN:   parentTree - The tree to add the dissection to
4325 *       tvb - The tvbbuff of packet data
4326 *       offset - The offset in TVB where the attribute begins
4327 *       MadHeader - The common MAD header of the current SMP/SMA  */
4328 static void parse_RandomForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4329 {
4330     gint i = 0;
4331     gint local_offset = *offset;
4332     proto_tree *RandomForwardingTable_header_tree = NULL;
4333     proto_item *RandomForwardingTable_header_item = NULL;
4334     proto_item *tempItemLow = NULL;
4335
4336     if(!parentTree)
4337         return;
4338
4339     RandomForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4340     proto_item_set_text(RandomForwardingTable_header_item, "%s", "RandomForwardingTable");
4341     RandomForwardingTable_header_tree = proto_item_add_subtree(RandomForwardingTable_header_item, ett_randomforwardingtable);
4342
4343     for(i = 0; i < 16; i++)
4344     {
4345         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4346         proto_item_append_text(tempItemLow, "(%u)", i);
4347         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Valid, tvb, local_offset, 1, ENC_BIG_ENDIAN);
4348         proto_item_append_text(tempItemLow, "(%u)", i);
4349         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LMC,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4350         proto_item_append_text(tempItemLow, "(%u)", i);
4351         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Port,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4352         proto_item_append_text(tempItemLow, "(%u)", i);
4353     }
4354 }
4355
4356 /* Parse NoticesAndTraps Attribute
4357 * IN:   parentTree - The tree to add the dissection to
4358 *       tvb - The tvbbuff of packet data
4359 *       offset - The offset in TVB where the attribute begins
4360 *       MadHeader - The common MAD header of the current SMP/SMA  */
4361 static void parse_MulticastForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4362 {
4363     gint i = 0;
4364     gint local_offset = *offset;
4365     proto_tree *MulticastForwardingTable_header_tree = NULL;
4366     proto_item *MulticastForwardingTable_header_item = NULL;
4367     proto_item *tempItemLow = NULL;
4368
4369     if(!parentTree)
4370         return;
4371
4372     MulticastForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4373     proto_item_set_text(MulticastForwardingTable_header_item, "%s", "MulticastForwardingTable");
4374     MulticastForwardingTable_header_tree = proto_item_add_subtree(MulticastForwardingTable_header_item, ett_multicastforwardingtable);
4375
4376     for(i = 0; i < 16; i++)
4377     {
4378         tempItemLow = proto_tree_add_item(MulticastForwardingTable_header_tree, hf_infiniband_MulticastForwardingTable_PortMask, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4379         proto_item_append_text(tempItemLow, "(%u)", i);
4380     }
4381
4382 }
4383
4384 /* Parse SMInfo Attribute
4385 * IN:   parentTree - The tree to add the dissection to
4386 *       tvb - The tvbbuff of packet data
4387 *       offset - The offset in TVB where the attribute begins
4388 *       MadHeader - The common MAD header of the current SMP/SMA  */
4389 static void parse_SMInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4390 {
4391     gint local_offset = *offset;
4392     proto_tree *SMInfo_header_tree = NULL;
4393     proto_item *SMInfo_header_item = NULL;
4394
4395     if(!parentTree)
4396         return;
4397
4398     SMInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4399     proto_item_set_text(SMInfo_header_item, "%s", "SMInfo");
4400     SMInfo_header_tree = proto_item_add_subtree(SMInfo_header_item, ett_sminfo);
4401
4402     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_GUID,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
4403     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SM_Key,    tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset +=8;
4404     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_ActCount,  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset +=4;
4405     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_Priority,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4406     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SMState,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4407 }
4408
4409 /* Parse VendorDiag Attribute
4410 * IN:   parentTree - The tree to add the dissection to
4411 *       tvb - The tvbbuff of packet data
4412 *       offset - The offset in TVB where the attribute begins
4413 *       MadHeader - The common MAD header of the current SMP/SMA  */
4414 static void parse_VendorDiag(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4415 {
4416     gint local_offset = *offset;
4417     proto_tree *VendorDiag_header_tree = NULL;
4418     proto_item *VendorDiag_header_item = NULL;
4419
4420     if(!parentTree)
4421         return;
4422
4423     VendorDiag_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4424     proto_item_set_text(VendorDiag_header_item, "%s", "VendorDiag");
4425     VendorDiag_header_tree = proto_item_add_subtree(VendorDiag_header_item, ett_vendordiag);
4426
4427     proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_NextIndex,     tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4428     proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_DiagData,      tvb, local_offset, 62, ENC_NA); local_offset +=62;
4429 }
4430
4431 /* Parse LedInfo Attribute
4432 * IN:   parentTree - The tree to add the dissection to
4433 *       tvb - The tvbbuff of packet data
4434 *       offset - The offset in TVB where the attribute begins
4435 *       MadHeader - The common MAD header of the current SMP/SMA  */
4436 static void parse_LedInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4437 {
4438     gint local_offset = *offset;
4439     proto_tree *LedInfo_header_tree = NULL;
4440     proto_item *LedInfo_header_item = NULL;
4441
4442     if(!parentTree)
4443         return;
4444
4445     LedInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4446     proto_item_set_text(LedInfo_header_item, "%s", "LedInfo");
4447     LedInfo_header_tree = proto_item_add_subtree(LedInfo_header_item, ett_ledinfo);
4448
4449     proto_tree_add_item(LedInfo_header_tree, hf_infiniband_LedInfo_LedMask,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
4450 }
4451
4452 /* Parse LinkSpeedWidthPairsTable Attribute
4453 * IN:   parentTree - The tree to add the dissection to
4454 *       tvb - The tvbbuff of packet data
4455 *       offset - The offset in TVB where the attribute begins
4456 *       MadHeader - The common MAD header of the current SMP/SMA  */
4457 static void parse_LinkSpeedWidthPairsTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4458 {
4459     gint local_offset = *offset;
4460     proto_tree *LinkSpeedWidthPairsTable_header_tree = NULL;
4461     proto_item *LinkSpeedWidthPairsTable_header_item = NULL;
4462
4463     if(!parentTree)
4464         return;
4465
4466     LinkSpeedWidthPairsTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4467     proto_item_set_text(LinkSpeedWidthPairsTable_header_item, "%s", "LinkSpeedWidthPairsTable");
4468     LinkSpeedWidthPairsTable_header_tree = proto_item_add_subtree(LinkSpeedWidthPairsTable_header_item, ett_linkspeedwidthpairs);
4469
4470     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_NumTables,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4471     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_PortMask,      tvb, local_offset, 32, ENC_NA); local_offset +=32;
4472     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4473     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4474     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset +=1;
4475 }
4476
4477 /* Parse RID Field from Subnet Administraiton Packets.
4478 * IN: SA_header_tree - the dissection tree of the subnet admin attribute.
4479 *     tvb - the packet buffer
4480 *      MadHeader - the Common MAD header from this packet.
4481 * IN/OUT:  offset - the current and updated offset in the packet buffer */
4482 static void parse_RID(proto_tree* SA_header_tree, tvbuff_t* tvb, gint *offset, MAD_Data* MadHeader)
4483 {
4484     gint local_offset = *offset;
4485     if(!SA_header_tree)
4486     {
4487         return;
4488     }
4489         switch(MadHeader->attributeID)
4490         {
4491             case 0x0011:
4492                 /* NodeRecord */
4493                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4494                 local_offset+=2; /* Reserved bits */
4495                 break;
4496             case 0x0012:
4497                 /* PortInfoRecord */
4498                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_EndportLID,    tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4499                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4500                 local_offset+=1; /* Reserved bits */
4501                 break;
4502             case 0x0013:
4503                 /* SLtoVLMappingTableRecord */
4504                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4505                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_InputPortNum,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4506                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4507                 local_offset+=4; /* Reserved bits */
4508                 break;
4509             case 0x0014:
4510                 /* SwitchInfoRecord */
4511                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4512                 local_offset+=2; /* Reserved bits */
4513                 break;
4514             case 0x0015:
4515                 /* LinearForwardingTableRecord */
4516                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4517                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4518                 local_offset+=4; /* Reserved bits */
4519                 break;
4520             case 0x0016:
4521                 /* RandomForwardingTableRecord */
4522                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4523                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4524                 local_offset+=4; /* Reserved bits */
4525                 break;
4526             case 0x0017:
4527                 /* MulticastForwardingTableRecord */
4528                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4529                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_Position,          tvb, local_offset, 1, ENC_BIG_ENDIAN);
4530                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_NineBit,  tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4531                 local_offset+=4; /* Reserved bits */
4532                 break;
4533             case 0x0036:
4534                 /*VLArbitrationTableRecord */
4535                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4536                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4537                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4538                 local_offset+=4; /* Reserved bits */
4539                 break;
4540             case 0x0018:
4541                 /* SMInfoRecord */
4542                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4543                 local_offset+=2; /* Reserved bits */
4544                 break;
4545             case 0x0033:
4546                 /* P_KeyTableRecord */
4547                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4548                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4549                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4550                 local_offset+=3; /* Reserved bits */
4551                 break;
4552             case 0x00F3:
4553                 /* InformInfoRecord */
4554                 proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_SubscriberGID,   tvb, local_offset, 16, ENC_NA); local_offset+=16;
4555                 proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_Enum,            tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4556                 local_offset+=6; /* Reserved bits */
4557                 break;
4558             case 0x0020:
4559                 /* LinkRecord */
4560                 proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromLID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4561                 proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromPort,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4562                 break;
4563             case 0x0031:
4564                 /* ServiceRecord */
4565                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceID,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset+=8;
4566                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceGID,     tvb, local_offset, 16, ENC_NA); local_offset+=16;
4567                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceP_Key,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4568                 local_offset+=2;
4569                 break;
4570             case 0x0038:
4571                 /* MCMemberRecord */
4572                 proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_MGID,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4573                 proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_PortGID,   tvb, local_offset, 16, ENC_NA); local_offset+=16;
4574                 break;
4575             case 0x0030:
4576                 /* GuidInfoRecord */
4577                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4578                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=2;
4579                 local_offset+=4;
4580                 break;
4581             default:
4582                 break;
4583         }
4584
4585     *offset = local_offset;
4586 }
4587
4588 /* Parse InformInfo Attribute
4589 * IN:   parentTree - The tree to add the dissection to
4590 *       tvb - The tvbbuff of packet data
4591 *       offset - The offset in TVB where the attribute begins
4592 *       MadHeader - The common MAD header of the current SMP/SMA  */
4593 static void parse_InformInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4594 {
4595     gint local_offset = *offset;
4596     proto_tree *InformInfo_header_tree = NULL;
4597     proto_item *InformInfo_header_item = NULL;
4598     if(!parentTree)
4599     {
4600         return;
4601     }
4602     InformInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 36, ENC_NA);
4603     proto_item_set_text(InformInfo_header_item, "%s", "InformInfo");
4604     InformInfo_header_tree = proto_item_add_subtree(InformInfo_header_item, ett_informinfo);
4605
4606     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_GID,                   tvb, local_offset, 16, ENC_NA); local_offset+=16;
4607     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeBegin,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4608     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeEnd,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4609     local_offset+=2; /* Reserved Bits */
4610     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_IsGeneric,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4611     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Subscribe,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4612     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Type,                  tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4613     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_TrapNumberDeviceID,    tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4614     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_QPN,                   tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
4615     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_RespTimeValue,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4616     local_offset+=1;
4617     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_ProducerTypeVendorID,  tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
4618
4619 }
4620 /* Parse LinkRecord Attribute
4621 * IN:   parentTree - The tree to add the dissection to
4622 *       tvb - The tvbbuff of packet data
4623 *       offset - The offset in TVB where the attribute begins
4624 *       MadHeader - The common MAD header of the current SMP/SMA  */
4625 static void parse_LinkRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4626 {
4627     gint local_offset = *offset;
4628     proto_tree *LinkRecord_header_tree = NULL;
4629     proto_item *LinkRecord_header_item = NULL;
4630
4631     if(!parentTree)
4632     {
4633         return;
4634     }
4635
4636     LinkRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 3, ENC_NA);
4637     proto_item_set_text(LinkRecord_header_item, "%s", "LinkRecord");
4638     LinkRecord_header_tree = proto_item_add_subtree(LinkRecord_header_item, ett_linkrecord);
4639
4640     proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToPort,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4641     proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToLID,     tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset +=2;
4642
4643 }
4644 /* Parse ServiceRecord Attribute
4645 * IN:   parentTree - The tree to add the dissection to
4646 *       tvb - The tvbbuff of packet data
4647 *       offset - The offset in TVB where the attribute begins
4648 *       MadHeader - The common MAD header of the current SMP/SMA  */
4649 static void parse_ServiceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4650 {
4651     gint local_offset = *offset;
4652     proto_tree *ServiceRecord_header_tree = NULL;
4653     proto_item *ServiceRecord_header_item = NULL;
4654     proto_item *tempData = NULL;
4655
4656     if(!parentTree)
4657     {
4658         return;
4659     }
4660
4661     ServiceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 176, ENC_NA);
4662     proto_item_set_text(ServiceRecord_header_item, "%s", "ServiceRecord");
4663     ServiceRecord_header_tree = proto_item_add_subtree(ServiceRecord_header_item, ett_servicerecord);
4664
4665     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceLease,    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
4666     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceKey,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4667     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceName,     tvb, local_offset, 64, ENC_NA); local_offset+=64;
4668
4669     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4670     proto_item_append_text(tempData, "%s", "(ServiceData 8.1, 8.16)");
4671     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4672     proto_item_append_text(tempData, "%s", "(ServiceData 16.1, 16.8)");
4673     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4674     proto_item_append_text(tempData, "%s", "(ServiceData 32.1, 32.4)");
4675     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset+=16;
4676     proto_item_append_text(tempData, "%s", "(ServiceData 64.1, 64.2)");
4677
4678 }
4679 /* Parse PathRecord Attribute
4680 * IN:   parentTree - The tree to add the dissection to
4681 *       tvb - The tvbbuff of packet data
4682 *       offset - The offset in TVB where the attribute begins
4683 *       MadHeader - The common MAD header of the current SMP/SMA  */
4684 static void parse_PathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4685 {
4686     gint local_offset = *offset;
4687     proto_tree *PathRecord_header_tree = NULL;
4688     proto_item *PathRecord_header_item = NULL;
4689
4690     if(!parentTree)
4691     {
4692         return;
4693     }
4694
4695     PathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA);
4696     proto_item_set_text(PathRecord_header_item, "%s", "PathRecord");
4697     PathRecord_header_tree = proto_item_add_subtree(PathRecord_header_item, ett_pathrecord);
4698     local_offset += 8; /* Reserved Bits */
4699
4700     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DGID,          tvb, local_offset, 16, ENC_NA); local_offset+=16;
4701     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SGID,          tvb, local_offset, 16, ENC_NA); local_offset+=16;
4702     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4703     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4704     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RawTraffic,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4705     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_FlowLabel,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
4706     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_HopLimit,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4707     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_TClass,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4708     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Reversible,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4709     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_NumbPath,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4710     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_P_Key,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4711     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SL,            tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4712     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTUSelector,   tvb, local_offset, 1, ENC_BIG_ENDIAN);
4713     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4714     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RateSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4715     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Rate,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4716     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTimeSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4717     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTime,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4718     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Preference,                tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4719 }
4720 /* Parse MCMemberRecord Attribute
4721 * IN:   parentTree - The tree to add the dissection to
4722 *       tvb - The tvbbuff of packet data
4723 *       offset - The offset in TVB where the attribute begins
4724 *       MadHeader - The common MAD header of the current SMP/SMA  */
4725 static void parse_MCMemberRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4726 {
4727     gint local_offset = *offset;
4728     proto_tree *MCMemberRecord_header_tree = NULL;
4729     proto_item *MCMemberRecord_header_item = NULL;
4730
4731     if(!parentTree)
4732     {
4733         return;
4734     }
4735
4736     MCMemberRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA);
4737     proto_item_set_text(MCMemberRecord_header_item, "%s", "MCMemberRecord");
4738     MCMemberRecord_header_tree = proto_item_add_subtree(MCMemberRecord_header_item, ett_mcmemberrecord);
4739
4740     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Q_Key,         tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset+=4;
4741     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4742     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTUSelector,   tvb, local_offset, 1, ENC_BIG_ENDIAN);
4743     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4744     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_TClass,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4745     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_P_Key,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4746     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_RateSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4747     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Rate,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4748     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTimeSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4749     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTime,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4750     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_SL,            tvb, local_offset, 1, ENC_BIG_ENDIAN);
4751     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_FlowLabel,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
4752     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_HopLimit,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4753     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Scope,         tvb, local_offset, 1, ENC_BIG_ENDIAN);
4754     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_JoinState,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4755     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_ProxyJoin,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=3;
4756
4757 }
4758 /* Parse TraceRecord Attribute
4759 * IN:   parentTree - The tree to add the dissection to
4760 *       tvb - The tvbbuff of packet data
4761 *       offset - The offset in TVB where the attribute begins
4762 *       MadHeader - The common MAD header of the current SMP/SMA  */
4763 static void parse_TraceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4764 {
4765     gint local_offset = *offset;
4766     proto_tree *TraceRecord_header_tree = NULL;
4767     proto_item *TraceRecord_header_item = NULL;
4768
4769     if(!parentTree)
4770     {
4771         return;
4772     }
4773
4774     TraceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 46, ENC_NA);
4775     proto_item_set_text(TraceRecord_header_item, "%s", "TraceRecord");
4776     TraceRecord_header_tree = proto_item_add_subtree(TraceRecord_header_item, ett_tracerecord);
4777
4778     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_GIDPrefix,       tvb, local_offset, 8, FALSE); local_offset+=8;
4779     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_IDGeneration,    tvb, local_offset, 2, FALSE); local_offset+=2;
4780     local_offset+=1; /* Reserved Bits */
4781     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeType,        tvb, local_offset, 1, FALSE); local_offset+=1;
4782     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeID,          tvb, local_offset, 8, FALSE); local_offset+=8;
4783     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ChassisID,       tvb, local_offset, 8, FALSE); local_offset+=8;
4784     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPortID,     tvb, local_offset, 8, FALSE); local_offset+=8;
4785     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPortID,      tvb, local_offset, 8, FALSE); local_offset+=8;
4786     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPort,       tvb, local_offset, 1, FALSE); local_offset+=1;
4787     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPort,        tvb, local_offset, 1, FALSE); local_offset+=1;
4788 }
4789 /* Parse MultiPathRecord Attribute
4790 * IN:   parentTree - The tree to add the dissection to
4791 *       tvb - The tvbbuff of packet data
4792 *       offset - The offset in TVB where the attribute begins
4793 *       MadHeader - The common MAD header of the current SMP/SMA  */
4794 static void parse_MultiPathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4795 {
4796     gint local_offset = *offset;
4797     proto_tree *MultiPathRecord_header_tree = NULL;
4798     proto_item *MultiPathRecord_header_item = NULL;
4799     proto_item *SDGID = NULL;
4800     guint8 SDGIDCount = 0;
4801     guint8 DGIDCount = 0;
4802     guint32 i = 0;
4803
4804     if(!parentTree)
4805     {
4806         return;
4807     }
4808
4809     MultiPathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 200, ENC_NA);
4810     proto_item_set_text(MultiPathRecord_header_item, "%s", "MultiPathRecord");
4811     MultiPathRecord_header_tree = proto_item_add_subtree(MultiPathRecord_header_item, ett_multipathrecord);
4812
4813     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RawTraffic,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4814     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_FlowLabel,       tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset+=3;
4815     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_HopLimit,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4816     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_TClass,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4817     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Reversible,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4818     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_NumbPath,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4819     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_P_Key,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4820     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SL,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset+=2;
4821     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTUSelector,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
4822     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTU,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4823     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RateSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4824     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Rate,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4825     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTimeSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4826     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTime,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4827     local_offset+=1; /* Reserved Bits */
4828     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_IndependenceSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4829     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_GIDScope,                tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4830
4831     SDGIDCount = tvb_get_guint8(tvb, local_offset);
4832     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SGIDCount,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4833     DGIDCount = tvb_get_guint8(tvb, local_offset);
4834     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_DGIDCount,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset+=1;
4835     local_offset+=7; /*Reserved Bits */
4836
4837     for(i = 0; i < SDGIDCount; i++)
4838     {
4839         SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID,       tvb, local_offset, 16, ENC_NA); local_offset+=16;
4840         proto_item_set_text(SDGID, "(%s%u)","SGID", i);
4841     }
4842     for(i = 0; i < DGIDCount; i++)
4843     {
4844         SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID,       tvb, local_offset, 16, ENC_NA); local_offset+=16;
4845         proto_item_set_text(SDGID, "(%s%u)","DGID", i);
4846     }
4847 }
4848 /* Parse ServiceAssociationRecord Attribute
4849 * IN:   parentTree - The tree to add the dissection to
4850 *       tvb - The tvbbuff of packet data
4851 *       offset - The offset in TVB where the attribute begins
4852 *       MadHeader - The common MAD header of the current SMP/SMA  */
4853 static void parse_ServiceAssociationRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4854 {
4855     gint local_offset = *offset;
4856     proto_tree *ServiceAssociationRecord_header_tree = NULL;
4857     proto_item *ServiceAssociationRecord_header_item = NULL;
4858
4859     if(!parentTree)
4860     {
4861         return;
4862     }
4863
4864     ServiceAssociationRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 80, ENC_NA);
4865     proto_item_set_text(ServiceAssociationRecord_header_item, "%s", "ServiceAssociationRecord");
4866     ServiceAssociationRecord_header_tree = proto_item_add_subtree(ServiceAssociationRecord_header_item, ett_serviceassocrecord);
4867
4868     proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceKey,        tvb, local_offset, 16, ENC_NA); local_offset +=16;
4869     proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceName,       tvb, local_offset, 64, ENC_ASCII|ENC_NA); local_offset +=64;
4870 }
4871
4872 /* Parse PortCounters MAD from the Performance management class.
4873 * IN:   parentTree - The tree to add the dissection to
4874 *       tvb - The tvbbuff of packet data
4875 *       offset - The offset in TVB where the attribute begins
4876 *       pinfo - The packet info structure with column information  */
4877 static void parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset)
4878 {
4879     proto_item *perf_item = NULL;
4880     proto_tree *perf_tree = NULL;
4881     gint local_offset = *offset;
4882
4883     col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCounters)");
4884
4885     perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCounters, tvb, local_offset, 40, ENC_NA);
4886     perf_tree = proto_item_add_subtree(perf_item, ett_perfclass);
4887
4888     local_offset += 40; /* skip reserved field */
4889     local_offset += 1;  /* skip reserved field */
4890     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortSelect,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4891     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4892     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_SymbolErrorCounter, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4893     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkErrorRecoveryCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4894     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkDownedCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4895     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4896     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4897     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4898     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitDiscards, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4899     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4900     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4901     local_offset += 1;  /* skip reserved field */
4902     proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_LocalLinkIntegrityErrors, tvb, local_offset*8, 4, FALSE);
4903     proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, tvb, local_offset*8 + 4, 4, FALSE); local_offset += 1;
4904     local_offset += 2;  /* skip reserved field */
4905     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_VL15Dropped, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4906     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4907     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4908     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4909     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4910
4911     *offset = local_offset; /* update caller's offset to point to end of the PortCounters payload */
4912     return;
4913 }
4914
4915 /* Parse PortCountersExtended MAD from the Performance management class.
4916 * IN:   parentTree - The tree to add the dissection to
4917 *       tvb - The tvbbuff of packet data
4918 *       offset - The offset in TVB where the attribute begins
4919 *       pinfo - The packet info structure with column information  */
4920 static void parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset)
4921 {
4922     proto_item *perf_item = NULL;
4923     proto_tree *perf_tree = NULL;
4924     gint local_offset = *offset;
4925
4926     col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCountersExtended)");
4927
4928     perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCountersExt, tvb, local_offset, 72, ENC_NA);
4929     perf_tree = proto_item_add_subtree(perf_item, ett_perfclass);
4930
4931     local_offset += 40; /* skip reserved field */
4932     local_offset += 1;  /* skip reserved field */
4933     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortSelect,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4934     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4935     local_offset += 4;  /* skip reserved field */
4936     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4937     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4938     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4939     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4940     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4941     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4942     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4943     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4944
4945     *offset = local_offset; /* update caller's offset to point to end of the PortCountersExt payload */
4946     return;
4947 }
4948
4949 /* dissect_general_info
4950 * Used to extract very few values from the packet in the case that full dissection is disabled by the user.
4951 * IN:
4952 *       tvb - The tvbbuff of packet data
4953 *       offset - The offset in TVB where the attribute begins
4954 *       pinfo - The packet info structure with column information
4955 *       starts_with_grh - If true this packets start with a GRH header, otherwise with LRH  */
4956 static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh)
4957 {
4958     guint8 lnh_val = 0;             /* The Link Next Header Value.  Tells us which headers are coming */
4959     gboolean bthFollows = FALSE;    /* Tracks if we are parsing a BTH.  This is a significant decision point */
4960     guint8 virtualLane = 0;         /* The Virtual Lane of the current Packet */
4961     guint8 opCode = 0;              /* OpCode from BTH header. */
4962     gint32 nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */
4963     guint8 nxtHdr = 0;              /* that must be available for that header. */
4964     struct e_in6_addr SRCgid;       /* Struct to display ipv6 Address */
4965     struct e_in6_addr DSTgid;       /* Struct to display ipv6 Address */
4966     guint8 management_class = 0;
4967     MAD_Data MadData;
4968
4969     if (starts_with_grh) {
4970         /* this is a RoCE packet, skip LRH parsing */
4971         lnh_val = IBA_GLOBAL;
4972         goto skip_lrh;
4973     }
4974
4975     virtualLane =  tvb_get_guint8(tvb, offset);
4976     virtualLane = virtualLane & 0xF0;
4977     offset+=1;
4978
4979     /* Save Link Next Header... This tells us what the next header is. */
4980     lnh_val =  tvb_get_guint8(tvb, offset);
4981     lnh_val = lnh_val & 0x03;
4982     offset+=1;
4983
4984     /* Set destination in packet view. */
4985     *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset);
4986     SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr);
4987
4988     offset+=4;
4989
4990     /* Set Source in packet view. */
4991     *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset);
4992     SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr);
4993
4994     offset+=2;
4995
4996 skip_lrh:
4997
4998     switch(lnh_val)
4999     {
5000         case IBA_GLOBAL:
5001             offset +=6;
5002             nxtHdr = tvb_get_guint8(tvb, offset);
5003             offset += 2;
5004
5005             tvb_get_ipv6(tvb, offset, &SRCgid);
5006
5007             /* Set source GID in packet view. */
5008             memcpy(src_addr, &SRCgid, GID_SIZE);
5009             SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr);
5010
5011             offset += 16;
5012
5013             tvb_get_ipv6(tvb, offset, &DSTgid);
5014
5015             /* Set destination GID in packet view. */
5016             memcpy(dst_addr, &DSTgid, GID_SIZE);
5017             SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr);
5018
5019             offset += 16;
5020
5021             if(nxtHdr != 0x1B)
5022             {
5023                 /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */
5024                 break;
5025             }
5026             /* else
5027              * {
5028              *      Fall through switch and start parsing Local Headers and BTH
5029              * }
5030              */
5031         case IBA_LOCAL:
5032             bthFollows = TRUE;
5033
5034             /* Get the OpCode - this tells us what headers are following */
5035             opCode = tvb_get_guint8(tvb, offset);
5036             col_append_str(pinfo->cinfo, COL_INFO, val_to_str((guint32)opCode, OpCodeMap, "Unknown OpCode"));
5037             offset +=12;
5038             break;
5039         case IP_NON_IBA:
5040             /* Raw IPv6 Packet */
5041             g_snprintf(dst_addr,  ADDR_MAX_LEN, "IPv6 over IB Packet");
5042             SET_ADDRESS(&pinfo->dst,  AT_STRINGZ, (int)strlen(dst_addr)+1, dst_addr);
5043             break;
5044         case RAW:
5045             break;
5046         default:
5047             break;
5048     }
5049
5050     if(bthFollows)
5051     {
5052         /* Find our next header sequence based on the Opcode
5053          * Since we're not doing dissection here, we just need the proper offsets to get our labels in packet view */
5054
5055         nextHeaderSequence = find_next_header_sequence((guint32) opCode);
5056         switch(nextHeaderSequence)
5057         {
5058             case RDETH_DETH_PAYLD:
5059                 offset += 4; /* RDETH */
5060                 offset += 8; /* DETH */
5061                 break;
5062             case RDETH_DETH_RETH_PAYLD:
5063                 offset += 4; /* RDETH */
5064                 offset += 8; /* DETH */
5065                 offset += 16; /* RETH */
5066                 break;
5067             case RDETH_DETH_IMMDT_PAYLD:
5068                 offset += 4; /* RDETH */
5069                 offset += 8; /* DETH */
5070                 offset += 4; /* IMMDT */
5071                 break;
5072             case RDETH_DETH_RETH_IMMDT_PAYLD:
5073                 offset += 4; /* RDETH */
5074                 offset += 8; /* DETH */
5075                 offset += 16; /* RETH */
5076                 offset += 4; /* IMMDT */
5077                 break;
5078             case RDETH_DETH_RETH:
5079                 offset += 4; /* RDETH */
5080                 offset += 8; /* DETH */
5081                 offset += 16; /* RETH */
5082                 break;
5083             case RDETH_AETH_PAYLD:
5084                 offset += 4; /* RDETH */
5085                 offset += 4; /* AETH */
5086                 break;
5087             case RDETH_PAYLD:
5088                 offset += 4; /* RDETH */
5089                 break;
5090             case RDETH_AETH:
5091                 offset += 4; /* RDETH */
5092                 offset += 4; /* AETH */
5093                 break;
5094             case RDETH_AETH_ATOMICACKETH:
5095                 offset += 4; /* RDETH */
5096                 offset += 4; /* AETH */
5097                 offset += 8; /* AtomicAckETH */
5098                 break;
5099             case RDETH_DETH_ATOMICETH:
5100                 offset += 4; /* RDETH */
5101                 offset += 8; /* DETH */
5102                 offset += 28; /* AtomicETH */
5103                 break;
5104             case RDETH_DETH:
5105                 offset += 4; /* RDETH */
5106                 offset += 8; /* DETH */
5107                 break;
5108             case DETH_PAYLD:
5109                 offset += 8; /* DETH */
5110                 break;
5111             case PAYLD:
5112                 break;
5113             case IMMDT_PAYLD:
5114                 offset += 4; /* IMMDT */
5115                 break;
5116             case RETH_PAYLD:
5117                 offset += 16; /* RETH */
5118                 break;
5119             case RETH:
5120                 offset += 16; /* RETH */
5121                 break;
5122             case AETH_PAYLD:
5123                 offset += 4; /* AETH */
5124                 break;
5125             case AETH:
5126                 offset += 4; /* AETH */
5127                 break;
5128             case AETH_ATOMICACKETH:
5129                 offset += 4; /* AETH */
5130                 offset += 8; /* AtomicAckETH */
5131                 break;
5132             case ATOMICETH:
5133                 offset += 28; /* AtomicETH */
5134                 break;
5135             case IETH_PAYLD:
5136                 offset += 4; /* IETH */
5137                 break;
5138             case DETH_IMMDT_PAYLD:
5139                 offset += 8; /* DETH */
5140                 offset += 4; /* IMMDT */
5141                 break;
5142             default:
5143                 break;
5144         }
5145     }
5146     if(virtualLane == 0xF0)
5147     {
5148         management_class =  tvb_get_guint8(tvb, offset + 1);
5149         if(((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END))
5150         || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END)))
5151         {
5152             return;
5153         }
5154         else if((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END))
5155         {
5156             return;
5157         }
5158         else if(((management_class == (guint8)0x00) || (management_class == (guint8)0x02))
5159             || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80))
5160             || ((management_class >= (guint8)0x82)))
5161         {
5162             return;
5163         }
5164         else /* we have a normal management_class */
5165         {
5166             parse_MAD_Common(NULL, tvb, &offset, &MadData);
5167             label_SUBM_Method(NULL, &MadData, pinfo);
5168             label_SUBM_Attribute(NULL, &MadData, pinfo);
5169         }
5170     }
5171
5172     return;
5173 }
5174
5175 /* Protocol Registration */
5176 void proto_register_infiniband(void)
5177 {
5178     module_t *infiniband_module;
5179
5180     /* Field dissector structures.
5181     * For reserved fields, reservedX denotes the reserved field is X bits in length.
5182     * e.g. reserved2 is a reserved field 2 bits in length.
5183     * The third parameter is a filter string associated for this field.
5184     * So for instance, to filter packets for a given virtual lane,
5185     * The filter (infiniband.LRH.vl == 3) or something similar would be used. */
5186
5187     /* XXX: ToDo: Verify against Infiniband 1.2.1 Specification                           */
5188     /*            Fields verified/corrected: Those after comment "XX: All following ..."  */
5189
5190     /* meanings for MAD method field */
5191     static const value_string mad_method_str[] = {
5192         { 0x01, "Get()" },
5193         { 0x02, "Set()" },
5194         { 0x81, "GetResp()" },
5195         { 0x03, "Send()" },
5196         { 0x05, "Trap()" },
5197         { 0x06, "Report()" },
5198         { 0x86, "ReportResp()" },
5199         { 0x07, "TrapRepress()" },
5200         { 0,    NULL }
5201     };
5202
5203     static hf_register_info hf[] = {
5204         /* Local Route Header (LRH) */
5205         { &hf_infiniband_LRH, {
5206                 "Local Route Header", "infiniband.lrh",
5207                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5208         },
5209         { &hf_infiniband_virtual_lane, {
5210                 "Virtual Lane", "infiniband.lrh.vl",
5211                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
5212         },
5213         { &hf_infiniband_link_version, {
5214                 "Link Version", "infiniband.lrh.lver",
5215                 FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}
5216         },
5217         { &hf_infiniband_service_level, {
5218                 "Service Level", "infiniband.lrh.sl",
5219                 FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}
5220         },
5221         { &hf_infiniband_reserved2, {
5222                 "Reserved (2 bits)", "infiniband.lrh.reserved2",
5223                 FT_UINT8, BASE_DEC, NULL, 0x0C, NULL, HFILL}
5224         },
5225         { &hf_infiniband_link_next_header, {
5226                 "Link Next Header", "infiniband.lrh.lnh",
5227                 FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL}
5228         },
5229         { &hf_infiniband_destination_local_id, {
5230                 "Destination Local ID", "infiniband.lrh.dlid",
5231                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5232         },
5233         { &hf_infiniband_reserved5, {
5234                 "Reserved (5 bits)", "infiniband.lrh.reserved5",
5235                 FT_UINT16, BASE_DEC, NULL, 0xF800, NULL, HFILL}
5236         },
5237         { &hf_infiniband_packet_length, {
5238                 "Packet Length", "infiniband.lrh.pktlen",
5239                 FT_UINT16, BASE_DEC, NULL, 0x07FF, NULL, HFILL}
5240         },
5241         { &hf_infiniband_source_local_id, {
5242                 "Source Local ID", "infiniband.lrh.slid",
5243                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5244         },
5245
5246         /* Global Route Header (GRH) */
5247         { &hf_infiniband_GRH, {
5248                 "Global Route Header", "infiniband.grh",
5249                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5250         },
5251         { &hf_infiniband_ip_version, {
5252                 "IP Version", "infiniband.grh.ipver",
5253                 FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}
5254         },
5255         { &hf_infiniband_traffic_class, {
5256                 "Traffic Class", "infiniband.grh.tclass",
5257                 FT_UINT16, BASE_DEC, NULL, 0x0FF0, NULL, HFILL}
5258         },
5259         { &hf_infiniband_flow_label, {
5260                 "Flow Label", "infiniband.grh.flowlabel",
5261                 FT_UINT32, BASE_DEC, NULL, 0x000FFFFF, NULL, HFILL}
5262         },
5263         { &hf_infiniband_payload_length, {
5264                 "Payload Length", "infiniband.grh.paylen",
5265                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5266         },
5267         { &hf_infiniband_next_header, {
5268                 "Next Header", "infiniband.grh.nxthdr",
5269                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5270         },
5271         { &hf_infiniband_hop_limit, {
5272                 "Hop Limit", "infiniband.grh.hoplmt",
5273                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5274         },
5275         { &hf_infiniband_source_gid, {
5276                 "Source GID", "infiniband.grh.sgid",
5277                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5278         },
5279         { &hf_infiniband_destination_gid, {
5280                 "Destination GID", "infiniband.grh.dgid",
5281                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5282         },
5283
5284         /* Base Transport Header (BTH) */
5285         { &hf_infiniband_BTH, {
5286                 "Base Transport Header", "infiniband.bth",
5287                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5288         },
5289         { &hf_infiniband_opcode, {
5290                 "Opcode", "infiniband.bth.opcode",
5291                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5292         },
5293         { &hf_infiniband_solicited_event, {
5294                 "Solicited Event", "infiniband.bth.se",
5295                 FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5296         },
5297         { &hf_infiniband_migreq, {
5298                 "MigReq", "infiniband.bth.m",
5299                 FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}
5300         },
5301         { &hf_infiniband_pad_count, {
5302                 "Pad Count", "infiniband.bth.padcnt",
5303                 FT_UINT8, BASE_DEC, NULL, 0x30, NULL, HFILL}
5304         },
5305         { &hf_infiniband_transport_header_version, {
5306                 "Header Version", "infiniband.bth.tver",
5307                 FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}
5308         },
5309         { &hf_infiniband_partition_key, {
5310                 "Partition Key", "infiniband.bth.p_key",
5311                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5312         },
5313         { &hf_infiniband_reserved8, {
5314                 "Reserved (8 bits)", "infiniband.bth.reserved8",
5315                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5316         },
5317         { &hf_infiniband_destination_qp, {
5318                 "Destination Queue Pair", "infiniband.bth.destqp",
5319                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5320         },
5321         { &hf_infiniband_acknowledge_request, {
5322                 "Acknowledge Request", "infiniband.bth.a",
5323                 FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5324         },
5325         { &hf_infiniband_reserved7, {
5326                 "Reserved (7 bits)", "infiniband.bth.reserved7",
5327                 FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL}
5328         },
5329         { &hf_infiniband_packet_sequence_number, {
5330                 "Packet Sequence Number", "infiniband.bth.psn",
5331                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5332         },
5333
5334         /* Raw Header (RWH) */
5335         { &hf_infiniband_RWH, {
5336                 "Raw Header", "infiniband.rwh",
5337                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5338         },
5339         { &hf_infiniband_reserved16_RWH, {
5340                 "Reserved (16 bits)", "infiniband.rwh.reserved",
5341                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5342         },
5343         { &hf_infiniband_etype, {
5344                 "Ethertype", "infiniband.rwh.etype",
5345                 FT_UINT16, BASE_HEX, NULL /*VALS(etype_vals)*/, 0x0, "Type", HFILL }
5346         },
5347
5348         /* Reliable Datagram Extended Transport Header (RDETH) */
5349         { &hf_infiniband_RDETH, {
5350                 "Reliable Datagram Extended Transport Header", "infiniband.rdeth",
5351                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5352         },
5353         { &hf_infiniband_reserved8_RDETH, {
5354                 "Reserved (8 bits)", "infiniband.rdeth.reserved8",
5355                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5356         },
5357         { &hf_infiniband_ee_context, {
5358                 "E2E Context", "infiniband.rdeth.eecnxt",
5359                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5360         },
5361
5362         /* Datagram Extended Transport Header (DETH) */
5363         { &hf_infiniband_DETH, {
5364                 "Datagram Extended Transport Header", "infiniband.deth",
5365                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5366         },
5367         { &hf_infiniband_queue_key, {
5368                 "Queue Key", "infiniband.deth.q_key",
5369                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5370         },
5371         { &hf_infiniband_reserved8_DETH, {
5372                 "Reserved (8 bits)", "infiniband.deth.reserved8",
5373                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5374         },
5375         { &hf_infiniband_source_qp, {
5376                 "Source Queue Pair", "infiniband.deth.srcqp",
5377                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5378         },
5379
5380         /* RDMA Extended Transport Header (RETH) */
5381         { &hf_infiniband_RETH, {
5382                 "RDMA Extended Transport Header", "infiniband.reth",
5383                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5384         },
5385         { &hf_infiniband_virtual_address, {
5386                 "Virtual Address", "infiniband.reth.va",
5387                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5388         },
5389         { &hf_infiniband_remote_key, {
5390                 "Remote Key", "infiniband.reth.r_key",
5391                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5392         },
5393         { &hf_infiniband_dma_length, {
5394                 "DMA Length", "infiniband.reth.dmalen",
5395                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5396         },
5397
5398         /* Atomic Extended Transport Header (AtomicETH) */
5399         { &hf_infiniband_AtomicETH, {
5400                 "Atomic Extended Transport Header", "infiniband.atomiceth",
5401                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5402         },
5403 #if 0
5404         { &hf_infiniband_virtual_address_AtomicETH, {
5405                 "Virtual Address", "infiniband.atomiceth.va",
5406                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5407         },
5408         { &hf_infiniband_remote_key_AtomicETH, {
5409                 "Remote Key", "infiniband.atomiceth.r_key",
5410                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5411         },
5412 #endif
5413         { &hf_infiniband_swap_or_add_data, {
5414                 "Swap (Or Add) Data", "infiniband.atomiceth.swapdt",
5415                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5416         },
5417         { &hf_infiniband_compare_data, {
5418                 "Compare Data", "infiniband.atomiceth.cmpdt",
5419                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5420         },
5421
5422         /* ACK Extended Transport Header (AETH) */
5423         { &hf_infiniband_AETH, {
5424                 "ACK Extended Transport Header", "infiniband.aeth",
5425                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5426         },
5427         { &hf_infiniband_syndrome, {
5428                 "Syndrome", "infiniband.aeth.syndrome",
5429                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5430         },
5431         { &hf_infiniband_message_sequence_number, {
5432                 "Message Sequence Number", "infiniband.aeth.msn",
5433                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5434         },
5435
5436         /* Atomic ACK Extended Transport Header (AtomicAckETH) */
5437         { &hf_infiniband_AtomicAckETH, {
5438                 "Atomic ACK Extended Transport Header", "infiniband.atomicacketh",
5439                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5440         },
5441         { &hf_infiniband_original_remote_data, {
5442                 "Original Remote Data", "infiniband.atomicacketh.origremdt",
5443                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5444         },
5445
5446         /* Immediate Extended Transport Header (ImmDT) */
5447         { &hf_infiniband_IMMDT, {
5448                 "Immediate Data", "infiniband.immdt",
5449                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5450         },
5451
5452         /* Invalidate Extended Transport Header (IETH) */
5453         { &hf_infiniband_IETH, {
5454                 "RKey", "infiniband.ieth",
5455                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5456         },
5457
5458         /* Payload */
5459         { &hf_infiniband_payload, {
5460                 "Payload", "infiniband.payload",
5461                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5462         },
5463         { &hf_infiniband_invariant_crc, {
5464                 "Invariant CRC", "infiniband.invariant.crc",
5465                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5466         },
5467         { &hf_infiniband_variant_crc, {
5468                 "Variant CRC", "infiniband.variant.crc",
5469                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5470         },
5471         { &hf_infiniband_raw_data, {
5472                 "Raw Data", "infiniband.rawdata",
5473                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5474         },
5475         /* Unknown or Vendor Specific */
5476         { &hf_infiniband_vendor, {
5477                 "Unknown/Vendor Specific Data", "infiniband.vendor",
5478                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5479         },
5480         /* CM REQ Header */
5481         {&hf_cm_req_local_comm_id, {
5482                 "Local Communication ID", "infiniband.cm.req",
5483                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5484         },
5485         {&hf_cm_req_service_id, {
5486                 "ServiceID", "infiniband.cm.req.serviceid",
5487                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5488         },
5489         {&hf_cm_req_local_ca_guid, {
5490                 "Local CA GUID", "infiniband.cm.req.localcaguid",
5491                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5492         },
5493         {&hf_cm_req_local_qkey, {
5494                 "Local Q_Key", "infiniband.cm.req.localqkey",
5495                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5496         },
5497         {&hf_cm_req_local_qpn, {
5498                 "Local QPN", "infiniband.cm.req.localqpn",
5499                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5500         },
5501         {&hf_cm_req_respo_res, {
5502                 "Responder Resources", "infiniband.cm.req.responderres",
5503                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5504         },
5505         {&hf_cm_req_local_eecn, {
5506                 "Local EECN", "infiniband.cm.req.localeecn",
5507                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5508         },
5509         {&hf_cm_req_init_depth, {
5510                 "Initiator Depth", "infiniband.cm.req.initdepth",
5511                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5512         },
5513         {&hf_cm_req_remote_eecn, {
5514                 "Remote EECN", "infiniband.cm.req.remoteeecn",
5515                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5516         },
5517         {&hf_cm_req_remote_cm_resp_to, {
5518                 "Remote CM Response Timeout", "infiniband.cm.req.remoteresptout",
5519                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5520         },
5521         {&hf_cm_req_transp_serv_type, {
5522                 "Transport Service Type", "infiniband.cm.req.transpsvctype",
5523                 FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL}
5524         },
5525         {&hf_cm_req_e2e_flow_ctrl, {
5526                 "End-to-End Flow Control", "infiniband.cm.req.e2eflowctrl",
5527                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5528         },
5529         {&hf_cm_req_start_psn, {
5530                 "Starting PSN", "infiniband.cm.req.startpsn",
5531                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5532         },
5533         {&hf_cm_req_local_cm_resp_to, {
5534                 "Local CM Response Timeout", "infiniband.cm.req.localresptout",
5535                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5536         },
5537         {&hf_cm_req_retry_count, {
5538                 "Retry Count", "infiniband.cm.req.retrcount",
5539                 FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL}
5540         },
5541         {&hf_cm_req_pkey, {
5542                 "Partition Key", "infiniband.cm.req.pkey",
5543                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5544         },
5545         {&hf_cm_req_path_pp_mtu, {
5546                 "Path Packet Payload MTU", "infiniband.cm.req.pppmtu",
5547                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5548         },
5549         {&hf_cm_req_rdc_exists, {
5550                 "RDC Exists", "infiniband.cm.req.rdcexist",
5551                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5552         },
5553         {&hf_cm_req_rnr_retry_count, {
5554                 "RNR Retry Count", "infiniband.cm.req.rnrretrcount",
5555                 FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL}
5556         },
5557         {&hf_cm_req_max_cm_retries, {
5558                 "Max CM Retries", "infiniband.cm.req.maxcmretr",
5559                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5560         },
5561         {&hf_cm_req_srq, {
5562                 "SRQ", "infiniband.cm.req.srq",
5563                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5564         },
5565         {&hf_cm_req_primary_local_lid, {
5566                 "Primary Local Port LID", "infiniband.cm.req.prim_locallid",
5567                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5568         },
5569         {&hf_cm_req_primary_remote_lid, {
5570                 "Primary Remote Port LID", "infiniband.cm.req.prim_remotelid",
5571                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5572         },
5573         {&hf_cm_req_primary_local_gid, {
5574                 "Primary Local Port GID", "infiniband.cm.req.prim_localgid",
5575                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5576         },
5577         {&hf_cm_req_primary_remote_gid, {
5578                 "Primary Remote Port GID", "infiniband.cm.req.prim_remotegid",
5579                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5580         },
5581         {&hf_cm_req_primary_flow_label, {
5582                 "Primary Flow Label", "infiniband.cm.req.prim_flowlabel",
5583                 FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL}
5584         },
5585         {&hf_cm_req_primary_packet_rate, {
5586                 "Primary Packet Rate", "infiniband.cm.req.prim_pktrate",
5587                 FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL}
5588         },
5589         {&hf_cm_req_primary_traffic_class, {
5590                 "Primary Traffic Class", "infiniband.cm.req.prim_tfcclass",
5591                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5592         },
5593         {&hf_cm_req_primary_hop_limit, {
5594                 "Primary Hop Limit", "infiniband.cm.req.prim_hoplim",
5595                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5596         },
5597         {&hf_cm_req_primary_sl, {
5598                 "Primary SL", "infiniband.cm.req.prim_sl",
5599                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5600         },
5601         {&hf_cm_req_primary_subnet_local, {
5602                 "Primary Subnet Local", "infiniband.cm.req.prim_subnetlocal",
5603                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5604         },
5605         {&hf_cm_req_primary_local_ack_to, {
5606                 "Primary Local ACK Timeout", "infiniband.cm.req.prim_localacktout",
5607                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5608         },
5609         {&hf_cm_req_alt_local_lid, {
5610                 "Alternate Local Port LID", "infiniband.cm.req.alt_locallid",
5611                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5612         },
5613         {&hf_cm_req_alt_remote_lid, {
5614                 "Alternate Remote Port LID", "infiniband.cm.req.alt_remotelid",
5615                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5616         },
5617         {&hf_cm_req_alt_local_gid, {
5618                 "Alternate Local Port GID", "infiniband.cm.req.alt_localgid",
5619                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5620         },
5621         {&hf_cm_req_alt_remote_gid, {
5622                 "Alternate Remote Port GID", "infiniband.cm.req.alt_remotegid",
5623                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5624         },
5625         {&hf_cm_req_flow_label, {
5626                 "Alternate Flow Label", "infiniband.cm.req.alt_flowlabel",
5627                 FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL}
5628         },
5629         {&hf_cm_req_packet_rate, {
5630                 "Alternate Packet Rate", "infiniband.cm.req.alt_pktrate",
5631                 FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL}
5632         },
5633         {&hf_cm_req_alt_traffic_class, {
5634                 "Alternate Traffic Class", "infiniband.cm.req.alt_tfcclass",
5635                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5636         },
5637         {&hf_cm_req_alt_hop_limit, {
5638                 "Alternate Hop Limit", "infiniband.cm.req.alt_hoplim",
5639                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5640         },
5641         {&hf_cm_req_SL, {
5642                 "Alternate SL", "infiniband.cm.req.alt_sl",
5643                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5644         },
5645         {&hf_cm_req_subnet_local, {
5646                 "Alternate Subnet Local", "infiniband.cm.req.alt_subnetlocal",
5647                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5648         },
5649         {&hf_cm_req_local_ACK_timeout, {
5650                 "Alternate Local ACK Timeout", "infiniband.cm.req.alt_localacktout",
5651                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5652         },
5653         {&hf_cm_req_private_data, {
5654                 "PrivateData", "infiniband.cm.req.private",
5655                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5656         },
5657         /* CM REP Header */
5658         {&hf_cm_rep_localcommid, {
5659                 "Local Communication ID", "infiniband.cm.rep",
5660                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5661         },
5662         {&hf_cm_rep_remotecommid, {
5663                 "Remote Communication ID", "infiniband.cm.rep.remotecommid",
5664                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5665         },
5666         {&hf_cm_rep_localqkey, {
5667                 "Local Q_Key", "infiniband.cm.rep.localqkey",
5668                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5669         },
5670         {&hf_cm_rep_localqpn, {
5671                 "Local QPN", "infiniband.cm.rep.localqpn",
5672                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5673         },
5674         {&hf_cm_rep_localeecontnum, {
5675                 "Local EE Context Number", "infiniband.cm.rep.localeecn",
5676                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5677         },
5678         {&hf_cm_rep_startingpsn, {
5679                 "Starting PSN", "infiniband.cm.rep.startpsn",
5680                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5681         },
5682         {&hf_cm_rep_responderres, {
5683                 "Responder Resources", "infiniband.cm.rep.respres",
5684                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5685         },
5686         {&hf_cm_rep_initiatordepth, {
5687                 "Initiator Depth", "infiniband.cm.rep.initdepth",
5688                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5689         },
5690         {&hf_cm_rep_tgtackdelay, {
5691                 "Target ACK Delay", "infiniband.cm.rep.tgtackdelay",
5692                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5693         },
5694         {&hf_cm_rep_failoveracc, {
5695                 "Failover Accepted", "infiniband.cm.rep.failoveracc",
5696                 FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL}
5697         },
5698         {&hf_cm_rep_e2eflowctl, {
5699                 "End-To-End Flow Control", "infiniband.cm.rep.e2eflowctrl",
5700                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5701         },
5702         {&hf_cm_rep_rnrretrycount, {
5703                 "RNR Retry Count", "infiniband.cm.rep.rnrretrcount",
5704                 FT_UINT8, BASE_HEX, NULL, 0x7, NULL, HFILL}
5705         },
5706         {&hf_cm_rep_srq, {
5707                 "SRQ", "infiniband.cm.rep.srq",
5708                 FT_UINT8, BASE_HEX, NULL, 0x8, NULL, HFILL}
5709         },
5710         {&hf_cm_rep_localcaguid, {
5711                 "Local CA GUID", "infiniband.cm.rep.localcaguid",
5712                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5713         },
5714         {&hf_cm_rep_privatedata, {
5715                 "PrivateData", "infiniband.cm.rep.private",
5716                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5717         },
5718         /* IB CM RTU Header */
5719         {&hf_cm_rtu_localcommid, {
5720                 "Local Communication ID", "infiniband.cm.rtu.localcommid",
5721                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5722         },
5723         {&hf_cm_rtu_remotecommid, {
5724                 "Remote Communication ID", "infiniband.cm.rtu.remotecommid",
5725                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5726         },
5727         {&hf_cm_rtu_privatedata, {
5728                 "PrivateData", "infiniband.cm.rtu.private",
5729                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5730         },
5731         /* CM REJ Header */
5732         {&hf_cm_rej_local_commid, {
5733                 "Local Communication ID", "infiniband.cm.rej.localcommid",
5734                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5735         },
5736         {&hf_cm_rej_remote_commid, {
5737                 "Remote Communication ID", "infiniband.cm.rej.remotecommid",
5738                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5739         },
5740         {&hf_cm_rej_msg_rej, {
5741                 "Message REJected", "infiniband.cm.rej.msgrej",
5742                 FT_UINT8, BASE_HEX, NULL, 0x3, NULL, HFILL}
5743         },
5744         {&hf_cm_rej_rej_info_len, {
5745                 "Reject Info Length", "infiniband.cm.rej.rejinfolen",
5746                 FT_UINT8, BASE_HEX, NULL, 0x7f, NULL, HFILL}
5747         },
5748         {&hf_cm_rej_reason, {
5749                 "Reason", "infiniband.cm.rej.reason",
5750                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5751         },
5752         {&hf_cm_rej_add_rej_info, {
5753                 "Additional Reject Information (ARI)", "infiniband.cm.rej.ari",
5754                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5755         },
5756         {&hf_cm_rej_private_data, {
5757                 "PrivateData", "infiniband.cm.rej.private",
5758                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5759         },
5760         /* MAD Base Header */
5761         { &hf_infiniband_MAD, {
5762                 "MAD (Management Datagram) Common Header", "infiniband.mad",
5763                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5764         },
5765         { &hf_infiniband_base_version, {
5766                 "Base Version", "infiniband.mad.baseversion",
5767                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5768         },
5769         { &hf_infiniband_mgmt_class, {
5770                 "Management Class", "infiniband.mad.mgmtclass",
5771                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5772         },
5773         { &hf_infiniband_class_version, {
5774                 "Class Version", "infiniband.mad.classversion",
5775                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5776         },
5777 #if 0
5778         { &hf_infiniband_reserved1, {
5779                 "Reserved", "infiniband.mad.reserved1",
5780                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5781         },
5782 #endif
5783         { &hf_infiniband_method, {
5784                 "Method", "infiniband.mad.method",
5785                 FT_UINT8, BASE_HEX, VALS(mad_method_str), 0x0, NULL, HFILL}
5786         },
5787         { &hf_infiniband_status, {
5788                 "Status", "infiniband.mad.status",
5789                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5790         },
5791         { &hf_infiniband_class_specific, {
5792                 "Class Specific", "infiniband.mad.classspecific",
5793                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5794         },
5795         { &hf_infiniband_transaction_id, {
5796                 "Transaction ID", "infiniband.mad.transactionid",
5797                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5798         },
5799         { &hf_infiniband_attribute_id, {
5800                 "Attribute ID", "infiniband.mad.attributeid",
5801                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5802         },
5803         { &hf_infiniband_reserved16, {
5804                 "Reserved", "infiniband.mad.reserved16",
5805                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5806         },
5807         { &hf_infiniband_attribute_modifier, {
5808                 "Attribute Modifier", "infiniband.mad.attributemodifier",
5809                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5810         },
5811         { &hf_infiniband_data, {
5812                 "MAD Data Payload", "infiniband.mad.data",
5813                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5814         },
5815
5816         /* RMPP Header */
5817         { &hf_infiniband_RMPP, {
5818                 "RMPP (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp",
5819                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5820         },
5821         { &hf_infiniband_rmpp_version, {
5822                 "RMPP Type", "infiniband.rmpp.rmppversion",
5823                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5824         },
5825         { &hf_infiniband_rmpp_type, {
5826                 "RMPP Type", "infiniband.rmpp.rmpptype",
5827                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5828         },
5829         { &hf_infiniband_r_resp_time, {
5830                 "R Resp Time", "infiniband.rmpp.rresptime",
5831                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
5832         },
5833         { &hf_infiniband_rmpp_flags, {
5834                 "RMPP Flags", "infiniband.rmpp.rmppflags",
5835                 FT_UINT8, BASE_HEX, VALS(RMPP_Flags), 0x0F, NULL, HFILL}
5836         },
5837         { &hf_infiniband_rmpp_status, {
5838                 "RMPP Status", "infiniband.rmpp.rmppstatus",
5839                 FT_UINT8, BASE_HEX, VALS(RMPP_Status), 0x0, NULL, HFILL}
5840         },
5841         { &hf_infiniband_rmpp_data1, {
5842                 "RMPP Data 1", "infiniband.rmpp.data1",
5843                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5844         },
5845         { &hf_infiniband_rmpp_data2, {
5846                 "RMPP Data 2", "infiniband.rmpp.data2",
5847                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5848         },
5849
5850     /* RMPP Data */
5851 #if 0
5852         { &hf_infiniband_RMPP_DATA, {
5853                 "RMPP Data (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp.data",
5854                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5855         },
5856 #endif
5857         { &hf_infiniband_segment_number, {
5858                 "Segment Number", "infiniband.rmpp.segmentnumber",
5859                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5860         },
5861         { &hf_infiniband_payload_length32, {
5862                 "Payload Length", "infiniband.rmpp.payloadlength",
5863                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5864         },
5865         { &hf_infiniband_transferred_data, {
5866                 "Transferred Data", "infiniband.rmpp.transferreddata",
5867                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5868         },
5869
5870         /* RMPP ACK */
5871         { &hf_infiniband_new_window_last, {
5872                 "New Window Last", "infiniband.rmpp.newwindowlast",
5873                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5874         },
5875         { &hf_infiniband_reserved220, {
5876                 "Segment Number", "infiniband.rmpp.reserved220",
5877                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5878         },
5879
5880         /* RMPP ABORT/STOP */
5881         { &hf_infiniband_optional_extended_error_data, {
5882                 "Optional Extended Error Data", "infiniband.rmpp.extendederrordata",
5883                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5884         },
5885
5886         /* SMP Data (LID Routed) */
5887         { &hf_infiniband_SMP_LID, {
5888                 "Subnet Management Packet (LID Routed)", "infiniband.smplid",
5889                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5890         },
5891         { &hf_infiniband_m_key, {
5892                 "M_Key", "infiniband.smplid.mkey",
5893                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5894         },
5895         { &hf_infiniband_smp_data, {
5896                 "SMP Data", "infiniband.smplid.smpdata",
5897                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5898         },
5899         { &hf_infiniband_reserved1024, {
5900                 "Reserved (1024 bits)", "infiniband.smplid.reserved1024",
5901                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5902         },
5903         { &hf_infiniband_reserved256, {
5904                 "Reserved (256 bits)", "infiniband.smplid.reserved256",
5905                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5906         },
5907
5908     /* XX: All following verified/corrected against Infiniband 1.2.1 Specification */
5909         /* SMP Data Directed Route */
5910         { &hf_infiniband_SMP_DIRECTED, {
5911                 "Subnet Management Packet (Directed Route)", "infiniband.smpdirected",
5912                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5913         },
5914         { &hf_infiniband_smp_status, {
5915                 "Status", "infiniband.smpdirected.smpstatus",
5916                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5917         },
5918         { &hf_infiniband_hop_pointer, {
5919                 "Hop Pointer", "infiniband.smpdirected.hoppointer",
5920                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5921         },
5922         { &hf_infiniband_hop_count, {
5923                 "Hop Count", "infiniband.smpdirected.hopcount",
5924                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5925         },
5926         { &hf_infiniband_dr_slid, {
5927                 "DrSLID", "infiniband.smpdirected.drslid",
5928                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5929         },
5930         { &hf_infiniband_dr_dlid, {
5931                 "DrDLID", "infiniband.smpdirected.drdlid",
5932                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5933         },
5934         { &hf_infiniband_reserved28, {
5935                 "Reserved (224 bits)", "infiniband.smpdirected.reserved28",
5936                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5937         },
5938         { &hf_infiniband_d, {
5939                 "D (Direction Bit)", "infiniband.smpdirected.d",
5940                 FT_UINT64, BASE_HEX, NULL, 0x8000, NULL, HFILL}
5941         },
5942         { &hf_infiniband_initial_path, {
5943                 "Initial Path", "infiniband.smpdirected.initialpath",
5944                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5945         },
5946         { &hf_infiniband_return_path, {
5947                 "Return Path", "infiniband.smpdirected.returnpath",
5948                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5949         },
5950
5951         /* SA MAD Header */
5952         { &hf_infiniband_SA, {
5953                 "SA Packet (Subnet Administration)", "infiniband.sa.drdlid",
5954                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5955         },
5956         { &hf_infiniband_sm_key, {
5957                 "SM_Key (Verification Key)", "infiniband.sa.smkey",
5958                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5959         },
5960         { &hf_infiniband_attribute_offset, {
5961                 "Attribute Offset", "infiniband.sa.attributeoffset",
5962                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5963         },
5964         { &hf_infiniband_component_mask, {
5965                 "Component Mask", "infiniband.sa.componentmask",
5966                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5967         },
5968         { &hf_infiniband_subnet_admin_data, {
5969                 "Subnet Admin Data", "infiniband.sa.subnetadmindata",
5970                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5971         },
5972
5973         /* Mellanox EoIB encapsulation header */
5974         { &hf_infiniband_EOIB, {
5975                 "Mellanox EoIB Encapsulation Header", "infiniband.eoib",
5976                 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}
5977         },
5978         { &hf_infiniband_ver, {
5979                 "Version", "infiniband.eoib.version",
5980                 FT_UINT16, BASE_HEX, NULL, 0x3000, NULL, HFILL}
5981         },
5982         { &hf_infiniband_tcp_chk, {
5983                 "TCP Checksum", "infiniband.eoib.tcp_chk",
5984                 FT_UINT16, BASE_HEX, NULL, 0x0c00, NULL, HFILL}
5985         },
5986         { &hf_infiniband_ip_chk, {
5987                 "IP Checksum", "infiniband.eoib.ip_chk",
5988                 FT_UINT16, BASE_HEX, NULL, 0x0300, NULL, HFILL}
5989         },
5990         { &hf_infiniband_fcs, {
5991                 "FCS Field Present", "infiniband.eoib.fcs",
5992                 FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL}
5993         },
5994         { &hf_infiniband_ms, {
5995                 "More Segments to Follow", "infiniband.eoib.ms",
5996                 FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL}
5997         },
5998         { &hf_infiniband_seg_off, {
5999                 "Segment Offset", "infiniband.eoib.ip_seg_offset",
6000                 FT_UINT16, BASE_DEC, NULL, 0x001f, NULL, HFILL}
6001         },
6002         { &hf_infiniband_seg_id, {
6003                 "Segment ID", "infiniband.eoib.ip_seg_id",
6004                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
6005         },
6006
6007         /* NodeDescription */
6008         { &hf_infiniband_NodeDescription_NodeString, {
6009                 "NodeString", "infiniband.nodedescription.nodestring",
6010                 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
6011         },
6012
6013         /* NodeInfo */
6014         { &hf_infiniband_NodeInfo_BaseVersion, {
6015                 "BaseVersion", "infiniband.nodeinfo.baseversion",
6016                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6017         },
6018         { &hf_infiniband_NodeInfo_ClassVersion, {
6019                 "ClassVersion", "infiniband.nodeinfo.classversion",
6020                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6021         },
6022         { &hf_infiniband_NodeInfo_NodeType, {
6023                 "NodeType", "infiniband.nodeinfo.nodetype",
6024                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6025         },
6026         { &hf_infiniband_NodeInfo_NumPorts, {
6027                 "NumPorts", "infiniband.nodeinfo.numports",
6028                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6029         },
6030         { &hf_infiniband_NodeInfo_SystemImageGUID, {
6031                 "SystemImageGUID", "infiniband.nodeinfo.systemimageguid",
6032                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6033         },
6034         { &hf_infiniband_NodeInfo_NodeGUID, {
6035                 "NodeGUID", "infiniband.nodeinfo.nodeguid",
6036                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6037         },
6038         { &hf_infiniband_NodeInfo_PortGUID, {
6039                 "PortGUID", "infiniband.nodeinfo.portguid",
6040                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6041         },
6042         { &hf_infiniband_NodeInfo_PartitionCap, {
6043                 "PartitionCap", "infiniband.nodeinfo.partitioncap",
6044                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6045         },
6046         { &hf_infiniband_NodeInfo_DeviceID, {
6047                 "DeviceID", "infiniband.nodeinfo.deviceid",
6048                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6049         },
6050         { &hf_infiniband_NodeInfo_Revision, {
6051                 "Revision", "infiniband.nodeinfo.revision",
6052                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6053         },
6054         { &hf_infiniband_NodeInfo_LocalPortNum, {
6055                 "LocalPortNum", "infiniband.nodeinfo.localportnum",
6056                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6057         },
6058         { &hf_infiniband_NodeInfo_VendorID, {
6059                 "VendorID", "infiniband.nodeinfo.vendorid",
6060                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6061         },
6062
6063         /* SwitchInfo */
6064         { &hf_infiniband_SwitchInfo_LinearFDBCap, {
6065                 "LinearFDBCap", "infiniband.switchinfo.linearfdbcap",
6066                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6067         },
6068         { &hf_infiniband_SwitchInfo_RandomFDBCap, {
6069                 "RandomFDBCap", "infiniband.switchinfo.randomfdbcap",
6070                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6071         },
6072         { &hf_infiniband_SwitchInfo_MulticastFDBCap, {
6073                 "MulticastFDBCap", "infiniband.switchinfo.multicastfdbcap",
6074                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6075         },
6076         { &hf_infiniband_SwitchInfo_LinearFDBTop, {
6077                 "LinearFDBTop", "infiniband.switchinfo.linearfdbtop",
6078                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6079         },
6080         { &hf_infiniband_SwitchInfo_DefaultPort, {
6081                 "DefaultPort", "infiniband.switchinfo.defaultport",
6082                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6083         },
6084         { &hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort, {
6085                 "DefaultMulticastPrimaryPort", "infiniband.switchinfo.defaultmulticastprimaryport",
6086                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6087         },
6088         { &hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort, {
6089                 "DefaultMulticastNotPrimaryPort", "infiniband.switchinfo.defaultmulticastnotprimaryport",
6090                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6091         },
6092         { &hf_infiniband_SwitchInfo_LifeTimeValue, {
6093                 "LifeTimeValue", "infiniband.switchinfo.lifetimevalue",
6094                 FT_UINT8, BASE_HEX, NULL, 0xF8, NULL, HFILL}
6095         },
6096         { &hf_infiniband_SwitchInfo_PortStateChange, {
6097                 "PortStateChange", "infiniband.switchinfo.portstatechange",
6098                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
6099         },
6100         { &hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, {
6101                 "OptimizedSLtoVLMappingProgramming", "infiniband.switchinfo.optimizedsltovlmappingprogramming",
6102                 FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL}
6103         },
6104         { &hf_infiniband_SwitchInfo_LIDsPerPort, {
6105                 "LIDsPerPort", "infiniband.switchinfo.lidsperport",
6106                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6107         },
6108         { &hf_infiniband_SwitchInfo_PartitionEnforcementCap, {
6109                 "PartitionEnforcementCap", "infiniband.switchinfo.partitionenforcementcap",
6110                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6111         },
6112         { &hf_infiniband_SwitchInfo_InboundEnforcementCap, {
6113                 "InboundEnforcementCap", "infiniband.switchinfo.inboundenforcementcap",
6114                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6115         },
6116         { &hf_infiniband_SwitchInfo_OutboundEnforcementCap, {
6117                 "OutboundEnforcementCap", "infiniband.switchinfo.outboundenforcementcap",
6118                 FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL}
6119         },
6120         { &hf_infiniband_SwitchInfo_FilterRawInboundCap, {
6121                 "FilterRawInboundCap", "infiniband.switchinfo.filterrawinboundcap",
6122                 FT_UINT8, BASE_HEX, NULL, 0x20, NULL, HFILL}
6123         },
6124         { &hf_infiniband_SwitchInfo_FilterRawOutboundCap, {
6125                 "FilterRawOutboundCap", "infiniband.switchinfo.filterrawoutboundcap",
6126                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
6127         },
6128         { &hf_infiniband_SwitchInfo_EnhancedPortZero, {
6129                 "EnhancedPortZero", "infiniband.switchinfo.enhancedportzero",
6130                 FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL}
6131         },
6132
6133         /* GUIDInfo */
6134 #if 0
6135         { &hf_infiniband_GUIDInfo_GUIDBlock, {
6136                 "GUIDBlock", "infiniband.switchinfo.guidblock",
6137                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6138         },
6139 #endif
6140         { &hf_infiniband_GUIDInfo_GUID, {
6141                 "GUID", "infiniband.switchinfo.guid",
6142                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6143         },
6144
6145         /* PortInfo */
6146         { &hf_infiniband_PortInfo_M_Key, {
6147                 "M_Key", "infiniband.portinfo.m_key",
6148                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6149         },
6150         { &hf_infiniband_PortInfo_GidPrefix, {
6151                 "GidPrefix", "infiniband.portinfo.guid",
6152                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6153         },
6154         { &hf_infiniband_PortInfo_LID, {
6155                 "LID", "infiniband.portinfo.lid",
6156                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6157         },
6158         { &hf_infiniband_PortInfo_MasterSMLID, {
6159                 "MasterSMLID", "infiniband.portinfo.mastersmlid",
6160                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6161         },
6162         { &hf_infiniband_PortInfo_CapabilityMask, {
6163                 "CapabilityMask", "infiniband.portinfo.capabilitymask",
6164                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6165         },
6166
6167         /* Capability Mask Flags */
6168         { &hf_infiniband_PortInfo_CapabilityMask_SM, {
6169                 "SM", "infiniband.portinfo.capabilitymask.issm",
6170                 FT_UINT32, BASE_HEX, NULL, 0x00000002, NULL, HFILL}
6171         },
6172         { &hf_infiniband_PortInfo_CapabilityMask_NoticeSupported, {
6173                 "NoticeSupported", "infiniband.portinfo.capabilitymask.noticesupported",
6174                 FT_UINT32, BASE_HEX, NULL, 0x00000004, NULL, HFILL}
6175         },
6176         { &hf_infiniband_PortInfo_CapabilityMask_TrapSupported, {
6177                 "TrapSupported", "infiniband.portinfo.capabilitymask.trapsupported",
6178                 FT_UINT32, BASE_HEX, NULL, 0x00000008, NULL, HFILL}
6179         },
6180         { &hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported, {
6181                 "OptionalPDSupported", "infiniband.portinfo.capabilitymask.optionalpdsupported",
6182                 FT_UINT32, BASE_HEX, NULL, 0x00000010, NULL, HFILL}
6183         },
6184         { &hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported, {
6185                 "AutomaticMigrationSupported", "infiniband.portinfo.capabilitymask.automaticmigrationsupported",
6186                 FT_UINT32, BASE_HEX, NULL, 0x00000020, NULL, HFILL}
6187         },
6188         { &hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported, {
6189                 "SLMappingSupported", "infiniband.portinfo.capabilitymask.slmappingsupported",
6190                 FT_UINT32, BASE_HEX, NULL, 0x00000040, NULL, HFILL}
6191         },
6192         { &hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM, {
6193                 "MKeyNVRAM", "infiniband.portinfo.capabilitymask.mkeynvram",
6194                 FT_UINT32, BASE_HEX, NULL, 0x00000080, NULL, HFILL}
6195         },
6196         { &hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM, {
6197                 "PKeyNVRAM", "infiniband.portinfo.capabilitymask.pkeynvram",
6198                 FT_UINT32, BASE_HEX, NULL, 0x00000100, NULL, HFILL}
6199         },
6200         { &hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported, {
6201                 "LEDInfoSupported", "infiniband.portinfo.capabilitymask.ledinfosupported",
6202                 FT_UINT32, BASE_HEX, NULL, 0x00000200, NULL, HFILL}
6203         },
6204         { &hf_infiniband_PortInfo_CapabilityMask_SMdisabled, {
6205                 "SMdisabled", "infiniband.portinfo.capabilitymask.smdisabled",
6206                 FT_UINT32, BASE_HEX, NULL, 0x00000400, NULL, HFILL}
6207         },
6208         { &hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported, {
6209                 "SystemImageGUIDSupported", "infiniband.portinfo.capabilitymask.systemimageguidsupported",
6210                 FT_UINT32, BASE_HEX, NULL, 0x00000800, NULL, HFILL}
6211         },
6212         { &hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported, {
6213                 "PKeySwitchExternalPortTrapSupported", "infiniband.portinfo.capabilitymask.pkeyswitchexternalporttrapsupported",
6214                 FT_UINT32, BASE_HEX, NULL, 0x00001000, NULL, HFILL}
6215         },
6216         { &hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported, {
6217                 "CommunicationsManagementSupported", "infiniband.portinfo.capabilitymask.communicationsmanagementsupported",
6218                 FT_UINT32, BASE_HEX, NULL, 0x00010000, NULL, HFILL}
6219         },
6220         { &hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported, {
6221                 "SNMPTunnelingSupported", "infiniband.portinfo.capabilitymask.snmptunnelingsupported",
6222                 FT_UINT32, BASE_HEX, NULL, 0x00020000, NULL, HFILL}
6223         },
6224         { &hf_infiniband_PortInfo_CapabilityMask_ReinitSupported, {
6225                 "ReinitSupported", "infiniband.portinfo.capabilitymask.reinitsupported",
6226                 FT_UINT32, BASE_HEX, NULL, 0x00040000, NULL, HFILL}
6227         },
6228         { &hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported, {
6229                 "DeviceManagementSupported", "infiniband.portinfo.capabilitymask.devicemanagementsupported",
6230                 FT_UINT32, BASE_HEX, NULL, 0x00080000, NULL, HFILL}
6231         },
6232         { &hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported, {
6233                 "VendorClassSupported", "infiniband.portinfo.capabilitymask.vendorclasssupported",
6234                 FT_UINT32, BASE_HEX, NULL, 0x00100000, NULL, HFILL}
6235         },
6236         { &hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported, {
6237                 "DRNoticeSupported", "infiniband.portinfo.capabilitymask.drnoticesupported",
6238                 FT_UINT32, BASE_HEX, NULL, 0x00200000, NULL, HFILL}
6239         },
6240         { &hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported, {
6241                 "CapabilityMaskNoticeSupported", "infiniband.portinfo.capabilitymask.capabilitymasknoticesupported",
6242                 FT_UINT32, BASE_HEX, NULL, 0x00400000, NULL, HFILL}
6243         },
6244         { &hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported, {
6245                 "BootManagementSupported", "infiniband.portinfo.capabilitymask.bootmanagementsupported",
6246                 FT_UINT32, BASE_HEX, NULL, 0x00800000, NULL, HFILL}
6247         },
6248         { &hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported, {
6249                 "LinkRoundTripLatencySupported", "infiniband.portinfo.capabilitymask.linkroundtriplatencysupported",
6250                 FT_UINT32, BASE_HEX, NULL, 0x01000000, NULL, HFILL}
6251         },
6252         { &hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported, {
6253                 "ClientRegistrationSupported", "infiniband.portinfo.capabilitymask.clientregistrationsupported",
6254                 FT_UINT32, BASE_HEX, NULL, 0x02000000, NULL, HFILL}
6255         },
6256         { &hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported, {
6257                 "OtherLocalChangesNoticeSupported", "infiniband.portinfo.capabilitymask.otherlocalchangesnoticesupported",
6258                 FT_UINT32, BASE_HEX, NULL, 0x04000000, NULL, HFILL}
6259         },
6260         { &hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported, {
6261                 "LinkSpeedWIdthPairsTableSupported", "infiniband.portinfo.capabilitymask.linkspeedwidthpairstablesupported",
6262                 FT_UINT32, BASE_HEX, NULL, 0x08000000, NULL, HFILL}
6263         },
6264         /* End Capability Mask Flags */
6265
6266         /* PortInfo */
6267         { &hf_infiniband_PortInfo_DiagCode, {
6268                 "DiagCode", "infiniband.portinfo.diagcode",
6269                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6270         },
6271         { &hf_infiniband_PortInfo_M_KeyLeasePeriod, {
6272                 "M_KeyLeasePeriod", "infiniband.portinfo.m_keyleaseperiod",
6273                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6274         },
6275         { &hf_infiniband_PortInfo_LocalPortNum, {
6276                 "LocalPortNum", "infiniband.portinfo.localportnum",
6277                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6278         },
6279         { &hf_infiniband_PortInfo_LinkWidthEnabled, {
6280                 "LinkWidthEnabled", "infiniband.portinfo.linkwidthenabled",
6281                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6282         },
6283         { &hf_infiniband_PortInfo_LinkWidthSupported, {
6284                 "LinkWidthSupported", "infiniband.portinfo.linkwidthsupported",
6285                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6286         },
6287         { &hf_infiniband_PortInfo_LinkWidthActive, {
6288                 "LinkWidthActive", "infiniband.portinfo.linkwidthactive",
6289                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6290         },
6291         { &hf_infiniband_PortInfo_LinkSpeedSupported, {
6292                 "LinkSpeedSupported", "infiniband.portinfo.linkspeedsupported",
6293                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6294         },
6295         { &hf_infiniband_PortInfo_PortState, {
6296                 "PortState", "infiniband.portinfo.portstate",
6297                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6298         },
6299         { &hf_infiniband_PortInfo_PortPhysicalState, {
6300                 "PortPhysicalState", "infiniband.portinfo.portphysicalstate",
6301                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6302         },
6303         { &hf_infiniband_PortInfo_LinkDownDefaultState, {
6304                 "LinkDownDefaultState", "infiniband.portinfo.linkdowndefaultstate",
6305                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6306         },
6307         { &hf_infiniband_PortInfo_M_KeyProtectBits, {
6308                 "M_KeyProtectBits", "infiniband.portinfo.m_keyprotectbits",
6309                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6310         },
6311         { &hf_infiniband_PortInfo_LMC, {
6312                 "LMC", "infiniband.portinfo.lmc",
6313                 FT_UINT8, BASE_HEX, NULL, 0x07, NULL, HFILL}
6314         },
6315         { &hf_infiniband_PortInfo_LinkSpeedActive, {
6316                 "LinkSpeedActive", "infiniband.portinfo.linkspeedactive",
6317                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6318         },
6319         { &hf_infiniband_PortInfo_LinkSpeedEnabled, {
6320                 "LinkSpeedEnabled", "infiniband.portinfo.linkspeedenabled",
6321                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6322         },
6323         { &hf_infiniband_PortInfo_NeighborMTU, {
6324                 "NeighborMTU", "infiniband.portinfo.neighbormtu",
6325                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6326         },
6327         { &hf_infiniband_PortInfo_MasterSMSL, {
6328                 "MasterSMSL", "infiniband.portinfo.mastersmsl",
6329                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6330         },
6331         { &hf_infiniband_PortInfo_VLCap, {
6332                 "VLCap", "infiniband.portinfo.vlcap",
6333                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6334         },
6335         { &hf_infiniband_PortInfo_InitType, {
6336                 "InitType", "infiniband.portinfo.inittype",
6337                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6338         },
6339         { &hf_infiniband_PortInfo_VLHighLimit, {
6340                 "VLHighLimit", "infiniband.portinfo.vlhighlimit",
6341                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6342         },
6343         { &hf_infiniband_PortInfo_VLArbitrationHighCap, {
6344                 "VLArbitrationHighCap", "infiniband.portinfo.vlarbitrationhighcap",
6345                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6346         },
6347         { &hf_infiniband_PortInfo_VLArbitrationLowCap, {
6348                 "VLArbitrationLowCap", "infiniband.portinfo.vlarbitrationlowcap",
6349                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6350         },
6351         { &hf_infiniband_PortInfo_InitTypeReply, {
6352                 "InitTypeReply", "infiniband.portinfo.inittypereply",
6353                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6354         },
6355         { &hf_infiniband_PortInfo_MTUCap, {
6356                 "MTUCap", "infiniband.portinfo.mtucap",
6357                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6358         },
6359         { &hf_infiniband_PortInfo_VLStallCount, {
6360                 "VLStallCount", "infiniband.portinfo.vlstallcount",
6361                 FT_UINT8, BASE_HEX, NULL, 0xE0, NULL, HFILL}
6362         },
6363         { &hf_infiniband_PortInfo_HOQLife, {
6364                 "HOQLife", "infiniband.portinfo.hoqlife",
6365                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6366         },
6367         { &hf_infiniband_PortInfo_OperationalVLs, {
6368                 "OperationalVLs", "infiniband.portinfo.operationalvls",
6369                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6370         },
6371         { &hf_infiniband_PortInfo_PartitionEnforcementInbound, {
6372                 "PartitionEnforcementInbound", "infiniband.portinfo.partitionenforcementinbound",
6373                 FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL}
6374         },
6375         { &hf_infiniband_PortInfo_PartitionEnforcementOutbound, {
6376                 "PartitionEnforcementOutbound", "infiniband.portinfo.partitionenforcementoutbound",
6377                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
6378         },
6379         { &hf_infiniband_PortInfo_FilterRawInbound, {
6380                 "FilterRawInbound", "infiniband.portinfo.filterrawinbound",
6381                 FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL}
6382         },
6383         { &hf_infiniband_PortInfo_FilterRawOutbound, {
6384                 "FilterRawOutbound", "infiniband.portinfo.filterrawoutbound",
6385                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
6386         },
6387         { &hf_infiniband_PortInfo_M_KeyViolations, {
6388                 "M_KeyViolations", "infiniband.portinfo.m_keyviolations",
6389                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6390         },
6391         { &hf_infiniband_PortInfo_P_KeyViolations, {
6392                 "P_KeyViolations", "infiniband.portinfo.p_keyviolations",
6393                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6394         },
6395         { &hf_infiniband_PortInfo_Q_KeyViolations, {
6396                 "Q_KeyViolations", "infiniband.portinfo.q_keyviolations",
6397                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6398         },
6399         { &hf_infiniband_PortInfo_GUIDCap, {
6400                 "GUIDCap", "infiniband.portinfo.guidcap",
6401                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6402         },
6403         { &hf_infiniband_PortInfo_ClientReregister, {
6404                 "ClientReregister", "infiniband.portinfo.clientreregister",
6405                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6406         },
6407         { &hf_infiniband_PortInfo_SubnetTimeOut, {
6408                 "SubnetTimeOut", "infiniband.portinfo.subnettimeout",
6409                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6410         },
6411         { &hf_infiniband_PortInfo_RespTimeValue, {
6412                 "RespTimeValue", "infiniband.portinfo.resptimevalue",
6413                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6414         },
6415         { &hf_infiniband_PortInfo_LocalPhyErrors, {
6416                 "LocalPhyErrors", "infiniband.portinfo.localphyerrors",
6417                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6418         },
6419         { &hf_infiniband_PortInfo_OverrunErrors, {
6420                 "OverrunErrors", "infiniband.portinfo.overrunerrors",
6421                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6422         },
6423         { &hf_infiniband_PortInfo_MaxCreditHint, {
6424                 "MaxCreditHint", "infiniband.portinfo.maxcredithint",
6425                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6426         },
6427         { &hf_infiniband_PortInfo_LinkRoundTripLatency, {
6428                 "LinkRoundTripLatency", "infiniband.portinfo.linkroundtriplatency",
6429                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6430         },
6431
6432         /* P_KeyTable */
6433         { &hf_infiniband_P_KeyTable_P_KeyTableBlock, {
6434                 "P_KeyTableBlock", "infiniband.p_keytable.p_keytableblock",
6435                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6436         },
6437         { &hf_infiniband_P_KeyTable_MembershipType, {
6438                 "MembershipType", "infiniband.p_keytable.membershiptype",
6439                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6440         },
6441         { &hf_infiniband_P_KeyTable_P_KeyBase, {
6442                 "P_KeyBase", "infiniband.p_keytable.p_keybase",
6443                 FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL}
6444         },
6445
6446         /* SLtoVLMappingTable */
6447         { &hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits, {
6448                 "SL(x)toVL", "infiniband.sltovlmappingtable.sltovlhighbits",
6449                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6450         },
6451         { &hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits, {
6452                 "SL(x)toVL", "infiniband.sltovlmappingtable.sltovllowbits",
6453                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6454         },
6455
6456         /* VLArbitrationTable */
6457 #if 0
6458         { &hf_infiniband_VLArbitrationTable_VLWeightPairs, {
6459                 "VLWeightPairs", "infiniband.vlarbitrationtable.vlweightpairs",
6460                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6461         },
6462 #endif
6463         { &hf_infiniband_VLArbitrationTable_VL, {
6464                 "VL", "infiniband.vlarbitrationtable.vl",
6465                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6466         },
6467         { &hf_infiniband_VLArbitrationTable_Weight, {
6468                 "Weight", "infiniband.vlarbitrationtable.weight",
6469                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6470         },
6471
6472         /* LinearForwardingTable */
6473 #if 0
6474         { &hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock, {
6475                 "LinearForwardingTableBlock", "infiniband.linearforwardingtable.linearforwardingtableblock",
6476                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6477         },
6478 #endif
6479         { &hf_infiniband_LinearForwardingTable_Port, {
6480                 "Port", "infiniband.linearforwardingtable.port",
6481                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6482         },
6483
6484         /* RandomForwardingTable */
6485 #if 0
6486         { &hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock, {
6487                 "RandomForwardingTableBlock", "infiniband.randomforwardingtable.randomforwardingtableblock",
6488                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6489         },
6490 #endif
6491         { &hf_infiniband_RandomForwardingTable_LID, {
6492                 "LID", "infiniband.randomforwardingtable.lid",
6493                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6494         },
6495         { &hf_infiniband_RandomForwardingTable_Valid, {
6496                 "Valid", "infiniband.randomforwardingtable.valid",
6497                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6498         },
6499         { &hf_infiniband_RandomForwardingTable_LMC, {
6500                 "LMC", "infiniband.randomforwardingtable.lmc",
6501                 FT_UINT8, BASE_HEX, NULL, 0x70, NULL, HFILL}
6502         },
6503         { &hf_infiniband_RandomForwardingTable_Port, {
6504                 "Port", "infiniband.randomforwardingtable.port",
6505                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6506         },
6507
6508         /* MulticastForwardingTable */
6509 #if 0
6510         { &hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock , {
6511                 "MulticastForwardingTableBlock", "infiniband.multicastforwardingtable.multicastforwardingtableblock",
6512                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6513         },
6514 #endif
6515         { &hf_infiniband_MulticastForwardingTable_PortMask, {
6516                 "PortMask", "infiniband.multicastforwardingtable.portmask",
6517                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6518         },
6519
6520         /* SMInfo */
6521         { &hf_infiniband_SMInfo_GUID, {
6522                 "GUID", "infiniband.sminfo.guid",
6523                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6524         },
6525         { &hf_infiniband_SMInfo_SM_Key, {
6526                 "SM_Key", "infiniband.sminfo.sm_key",
6527                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6528         },
6529         { &hf_infiniband_SMInfo_ActCount, {
6530                 "ActCount", "infiniband.sminfo.actcount",
6531                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6532         },
6533         { &hf_infiniband_SMInfo_Priority, {
6534                 "Priority", "infiniband.sminfo.priority",
6535                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6536         },
6537         { &hf_infiniband_SMInfo_SMState, {
6538                 "SMState", "infiniband.sminfo.smstate",
6539                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6540         },
6541
6542         /* VendorDiag */
6543         { &hf_infiniband_VendorDiag_NextIndex, {
6544                 "NextIndex", "infiniband.vendordiag.nextindex",
6545                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6546         },
6547         { &hf_infiniband_VendorDiag_DiagData, {
6548                 "DiagData", "infiniband.vendordiag.diagdata",
6549                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6550         },
6551
6552         /* LedInfo */
6553         { &hf_infiniband_LedInfo_LedMask, {
6554                 "LedMask", "infiniband.ledinfo.ledmask",
6555                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6556         },
6557
6558         /* LinkSpeedWidthPairsTable */
6559         { &hf_infiniband_LinkSpeedWidthPairsTable_NumTables, {
6560                 "NumTables", "infiniband.linkspeedwidthpairstable.numtables",
6561                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6562         },
6563         { &hf_infiniband_LinkSpeedWidthPairsTable_PortMask, {
6564                 "PortMask", "infiniband.linkspeedwidthpairstable.portmask",
6565                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6566         },
6567         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive, {
6568                 "Speed 2.5 Gbps", "infiniband.linkspeedwidthpairstable.speedtwofive",
6569                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6570         },
6571         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive, {
6572                 "Speed 5 Gbps", "infiniband.linkspeedwidthpairstable.speedfive",
6573                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6574         },
6575         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen, {
6576                 "Speed 10 Gbps", "infiniband.linkspeedwidthpairstable.speedten",
6577                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6578         },
6579
6580         /* NodeRecord */
6581         /* PortInfoRecord */
6582         /* SLtoVLMappingTableRecord */
6583         /* SwitchInfoRecord */
6584         /* LinearForwardingTableRecord */
6585         /* RandomForwardingTableRecord */
6586         /* MulticastForwardingTableRecord */
6587         /* VLArbitrationTableRecord */
6588         { &hf_infiniband_SA_LID, {
6589                 "LID", "infiniband.sa.lid",
6590                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6591         },
6592         { &hf_infiniband_SA_EndportLID, {
6593                 "EndportLID", "infiniband.sa.endportlid",
6594                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6595         },
6596         { &hf_infiniband_SA_PortNum, {
6597                 "PortNum", "infiniband.sa.portnum",
6598                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6599         },
6600         { &hf_infiniband_SA_InputPortNum , {
6601                 "InputPortNum", "infiniband.sa.inputportnum",
6602                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6603         },
6604         { &hf_infiniband_SA_OutputPortNum, {
6605                 "OutputPortNum", "infiniband.sa.outputportnum",
6606                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6607         },
6608         { &hf_infiniband_SA_BlockNum_EightBit, {
6609                 "BlockNum_EightBit", "infiniband.sa.blocknum_eightbit",
6610                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6611         },
6612         { &hf_infiniband_SA_BlockNum_NineBit, {
6613                 "BlockNum_NineBit", "infiniband.sa.blocknum_ninebit",
6614                 FT_UINT16, BASE_HEX, NULL, 0x01FF, NULL, HFILL}
6615         },
6616         { &hf_infiniband_SA_BlockNum_SixteenBit, {
6617                 "BlockNum_SixteenBit", "infiniband.sa.blocknum_sixteenbit",
6618                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6619         },
6620         { &hf_infiniband_SA_Position, {
6621                 "Position", "infiniband.sa.position",
6622                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6623         },
6624 #if 0
6625         { &hf_infiniband_SA_Index, {
6626                 "Index", "infiniband.sa.index",
6627                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6628         },
6629 #endif
6630
6631         /* InformInfoRecord */
6632         { &hf_infiniband_InformInfoRecord_SubscriberGID, {
6633                 "SubscriberGID", "infiniband.informinforecord.subscribergid",
6634                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6635         },
6636         { &hf_infiniband_InformInfoRecord_Enum, {
6637                 "Enum", "infiniband.informinforecord.enum",
6638                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6639         },
6640
6641         /* InformInfo */
6642         { &hf_infiniband_InformInfo_GID, {
6643                 "GID", "infiniband.informinfo.gid",
6644                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6645         },
6646         { &hf_infiniband_InformInfo_LIDRangeBegin, {
6647                 "LIDRangeBegin", "infiniband.informinfo.lidrangebegin",
6648                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6649         },
6650         { &hf_infiniband_InformInfo_LIDRangeEnd, {
6651                 "LIDRangeEnd", "infiniband.informinfo.lidrangeend",
6652                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6653         },
6654         { &hf_infiniband_InformInfo_IsGeneric, {
6655                 "IsGeneric", "infiniband.informinfo.isgeneric",
6656                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6657         },
6658         { &hf_infiniband_InformInfo_Subscribe, {
6659                 "Subscribe", "infiniband.informinfo.subscribe",
6660                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6661         },
6662         { &hf_infiniband_InformInfo_Type, {
6663                 "Type", "infiniband.informinfo.type",
6664                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6665         },
6666         { &hf_infiniband_InformInfo_TrapNumberDeviceID, {
6667                 "TrapNumberDeviceID", "infiniband.informinfo.trapnumberdeviceid",
6668                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6669         },
6670         { &hf_infiniband_InformInfo_QPN, {
6671                 "QPN", "infiniband.informinfo.qpn",
6672                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6673         },
6674         { &hf_infiniband_InformInfo_RespTimeValue, {
6675                 "RespTimeValue", "infiniband.informinfo.resptimevalue",
6676                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6677         },
6678         { &hf_infiniband_InformInfo_ProducerTypeVendorID, {
6679                 "ProducerTypeVendorID", "infiniband.informinfo.producertypevendorid",
6680                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6681         },
6682
6683         /* LinkRecord */
6684         { &hf_infiniband_LinkRecord_FromLID, {
6685                 "FromLID", "infiniband.linkrecord.fromlid",
6686                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6687         },
6688         { &hf_infiniband_LinkRecord_FromPort, {
6689                 "FromPort", "infiniband.linkrecord.fromport",
6690                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6691         },
6692         { &hf_infiniband_LinkRecord_ToPort, {
6693                 "ToPort", "infiniband.linkrecord.toport",
6694                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6695         },
6696         { &hf_infiniband_LinkRecord_ToLID, {
6697                 "ToLID", "infiniband.linkrecord.tolid",
6698                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6699         },
6700
6701         /* ServiceRecord */
6702         { &hf_infiniband_ServiceRecord_ServiceID, {
6703                 "ServiceID", "infiniband.linkrecord.serviceid",
6704                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6705         },
6706         { &hf_infiniband_ServiceRecord_ServiceGID, {
6707                 "ServiceGID", "infiniband.linkrecord.servicegid",
6708                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6709         },
6710         { &hf_infiniband_ServiceRecord_ServiceP_Key, {
6711                 "ServiceP_Key", "infiniband.linkrecord.servicep_key",
6712                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6713         },
6714         { &hf_infiniband_ServiceRecord_ServiceLease, {
6715                 "ServiceLease", "infiniband.linkrecord.servicelease",
6716                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6717         },
6718         { &hf_infiniband_ServiceRecord_ServiceKey, {
6719                 "ServiceKey", "infiniband.linkrecord.servicekey",
6720                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6721         },
6722         { &hf_infiniband_ServiceRecord_ServiceName, {
6723                 "ServiceName", "infiniband.linkrecord.servicename",
6724                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6725         },
6726         { &hf_infiniband_ServiceRecord_ServiceData, {
6727                 "ServiceData", "infiniband.linkrecord.servicedata",
6728                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6729         },
6730
6731         /* ServiceAssociationRecord */
6732         { &hf_infiniband_ServiceAssociationRecord_ServiceKey, {
6733                 "ServiceKey", "infiniband.serviceassociationrecord.servicekey",
6734                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6735         },
6736         { &hf_infiniband_ServiceAssociationRecord_ServiceName, {
6737                 "ServiceName", "infiniband.serviceassociationrecord.servicename",
6738                 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
6739         },
6740
6741         /* PathRecord */
6742         { &hf_infiniband_PathRecord_DGID, {
6743                 "DGID", "infiniband.pathrecord.dgid",
6744                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6745         },
6746         { &hf_infiniband_PathRecord_SGID, {
6747                 "SGID", "infiniband.pathrecord.sgid",
6748                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6749         },
6750         { &hf_infiniband_PathRecord_DLID, {
6751                 "DLID", "infiniband.pathrecord.dlid",
6752                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6753         },
6754         { &hf_infiniband_PathRecord_SLID, {
6755                 "SLID", "infiniband.pathrecord.slid",
6756                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6757         },
6758         { &hf_infiniband_PathRecord_RawTraffic, {
6759                 "RawTraffic", "infiniband.pathrecord.rawtraffic",
6760                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6761         },
6762         { &hf_infiniband_PathRecord_FlowLabel, {
6763                 "FlowLabel", "infiniband.pathrecord.flowlabel",
6764                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6765         },
6766         { &hf_infiniband_PathRecord_HopLimit, {
6767                 "HopLimit", "infiniband.pathrecord.hoplimit",
6768                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6769         },
6770         { &hf_infiniband_PathRecord_TClass, {
6771                 "TClass", "infiniband.pathrecord.tclass",
6772                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6773         },
6774         { &hf_infiniband_PathRecord_Reversible, {
6775                 "Reversible", "infiniband.pathrecord.reversible",
6776                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6777         },
6778         { &hf_infiniband_PathRecord_NumbPath, {
6779                 "NumbPath", "infiniband.pathrecord.numbpath",
6780                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6781         },
6782         { &hf_infiniband_PathRecord_P_Key, {
6783                 "P_Key", "infiniband.pathrecord.p_key",
6784                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6785         },
6786         { &hf_infiniband_PathRecord_SL, {
6787                 "SL", "infiniband.pathrecord.sl",
6788                 FT_UINT16, BASE_HEX, NULL, 0x000F, NULL, HFILL}
6789         },
6790         { &hf_infiniband_PathRecord_MTUSelector, {
6791                 "MTUSelector", "infiniband.pathrecord.mtuselector",
6792                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6793         },
6794         { &hf_infiniband_PathRecord_MTU, {
6795                 "MTU", "infiniband.pathrecord.mtu",
6796                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6797         },
6798         { &hf_infiniband_PathRecord_RateSelector, {
6799                 "RateSelector", "infiniband.pathrecord.rateselector",
6800                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6801         },
6802         { &hf_infiniband_PathRecord_Rate, {
6803                 "Rate", "infiniband.pathrecord.rate",
6804                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6805         },
6806         { &hf_infiniband_PathRecord_PacketLifeTimeSelector, {
6807                 "PacketLifeTimeSelector", "infiniband.pathrecord.packetlifetimeselector",
6808                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6809         },
6810         { &hf_infiniband_PathRecord_PacketLifeTime, {
6811                 "PacketLifeTime", "infiniband.pathrecord.packetlifetime",
6812                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6813         },
6814         { &hf_infiniband_PathRecord_Preference, {
6815                 "Preference", "infiniband.pathrecord.preference",
6816                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6817         },
6818
6819         /* MCMemberRecord */
6820         { &hf_infiniband_MCMemberRecord_MGID, {
6821                 "MGID", "infiniband.mcmemberrecord.mgid",
6822                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6823         },
6824         { &hf_infiniband_MCMemberRecord_PortGID, {
6825                 "PortGID", "infiniband.mcmemberrecord.portgid",
6826                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6827         },
6828         { &hf_infiniband_MCMemberRecord_Q_Key, {
6829                 "Q_Key", "infiniband.mcmemberrecord.q_key",
6830                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6831         },
6832         { &hf_infiniband_MCMemberRecord_MLID, {
6833                 "MLID", "infiniband.mcmemberrecord.mlid",
6834                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6835         },
6836         { &hf_infiniband_MCMemberRecord_MTUSelector, {
6837                 "MTUSelector", "infiniband.mcmemberrecord.mtuselector",
6838                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6839         },
6840         { &hf_infiniband_MCMemberRecord_MTU, {
6841                 "MTU", "infiniband.mcmemberrecord.mtu",
6842                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6843         },
6844         { &hf_infiniband_MCMemberRecord_TClass, {
6845                 "TClass", "infiniband.mcmemberrecord.tclass",
6846                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6847         },
6848         { &hf_infiniband_MCMemberRecord_P_Key, {
6849                 "P_Key", "infiniband.mcmemberrecord.p_key",
6850                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6851         },
6852         { &hf_infiniband_MCMemberRecord_RateSelector, {
6853                 "RateSelector", "infiniband.mcmemberrecord.rateselector",
6854                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6855         },
6856         { &hf_infiniband_MCMemberRecord_Rate, {
6857                 "Rate", "infiniband.mcmemberrecord.rate",
6858                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6859         },
6860         { &hf_infiniband_MCMemberRecord_PacketLifeTimeSelector, {
6861                 "PacketLifeTimeSelector", "infiniband.mcmemberrecord.packetlifetimeselector",
6862                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6863         },
6864         { &hf_infiniband_MCMemberRecord_PacketLifeTime, {
6865                 "PacketLifeTime", "infiniband.mcmemberrecord.packetlifetime",
6866                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6867         },
6868         { &hf_infiniband_MCMemberRecord_SL, {
6869                 "SL", "infiniband.mcmemberrecord.sl",
6870                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6871         },
6872         { &hf_infiniband_MCMemberRecord_FlowLabel, {
6873                 "FlowLabel", "infiniband.mcmemberrecord.flowlabel",
6874                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6875         },
6876         { &hf_infiniband_MCMemberRecord_HopLimit, {
6877                 "HopLimit", "infiniband.mcmemberrecord.hoplimit",
6878                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6879         },
6880         { &hf_infiniband_MCMemberRecord_Scope, {
6881                 "Scope", "infiniband.mcmemberrecord.scope",
6882                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6883         },
6884         { &hf_infiniband_MCMemberRecord_JoinState, {
6885                 "JoinState", "infiniband.mcmemberrecord.joinstate",
6886                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6887         },
6888         { &hf_infiniband_MCMemberRecord_ProxyJoin, {
6889                 "ProxyJoin", "infiniband.mcmemberrecord.proxyjoin",
6890                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6891         },
6892
6893         /* MultiPathRecord */
6894         { &hf_infiniband_MultiPathRecord_RawTraffic, {
6895                 "RawTraffic", "infiniband.multipathrecord.rawtraffic",
6896                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6897         },
6898         { &hf_infiniband_MultiPathRecord_FlowLabel, {
6899                 "FlowLabel", "infiniband.multipathrecord.flowlabel",
6900                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6901         },
6902         { &hf_infiniband_MultiPathRecord_HopLimit, {
6903                 "HopLimit", "infiniband.multipathrecord.hoplimit",
6904                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6905         },
6906         { &hf_infiniband_MultiPathRecord_TClass, {
6907                 "TClass", "infiniband.multipathrecord.tclass",
6908                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6909         },
6910         { &hf_infiniband_MultiPathRecord_Reversible, {
6911                 "Reversible", "infiniband.multipathrecord.reversible",
6912                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6913         },
6914         { &hf_infiniband_MultiPathRecord_NumbPath, {
6915                 "NumbPath", "infiniband.multipathrecord.numbpath",
6916                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6917         },
6918         { &hf_infiniband_MultiPathRecord_P_Key, {
6919                 "P_Key", "infiniband.multipathrecord.p_key",
6920                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6921         },
6922         { &hf_infiniband_MultiPathRecord_SL, {
6923                 "SL", "infiniband.multipathrecord.sl",
6924                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6925         },
6926         { &hf_infiniband_MultiPathRecord_MTUSelector, {
6927                 "MTUSelector", "infiniband.multipathrecord.mtuselector",
6928                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6929         },
6930         { &hf_infiniband_MultiPathRecord_MTU, {
6931                 "MTU", "infiniband.multipathrecord.mtu",
6932                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6933         },
6934         { &hf_infiniband_MultiPathRecord_RateSelector, {
6935                 "RateSelector", "infiniband.multipathrecord.rateselector",
6936                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6937         },
6938         { &hf_infiniband_MultiPathRecord_Rate, {
6939                 "Rate", "infiniband.multipathrecord.rate",
6940                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6941         },
6942         { &hf_infiniband_MultiPathRecord_PacketLifeTimeSelector, {
6943                 "PacketLifeTimeSelector", "infiniband.multipathrecord.packetlifetimeselector",
6944                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6945         },
6946         { &hf_infiniband_MultiPathRecord_PacketLifeTime, {
6947                 "PacketLifeTime", "infiniband.multipathrecord.packetlifetime",
6948                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6949         },
6950         { &hf_infiniband_MultiPathRecord_IndependenceSelector, {
6951                 "IndependenceSelector", "infiniband.multipathrecord.independenceselector",
6952                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6953         },
6954         { &hf_infiniband_MultiPathRecord_GIDScope, {
6955                 "GIDScope", "infiniband.multipathrecord.gidscope",
6956                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6957         },
6958         { &hf_infiniband_MultiPathRecord_SGIDCount, {
6959                 "SGIDCount", "infiniband.multipathrecord.sgidcount",
6960                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6961         },
6962         { &hf_infiniband_MultiPathRecord_DGIDCount, {
6963                 "DGIDCount", "infiniband.multipathrecord.dgidcount",
6964                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6965         },
6966         { &hf_infiniband_MultiPathRecord_SDGID, {
6967                 "SDGID", "infiniband.multipathrecord.sdgid",
6968                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6969         },
6970
6971         /* Notice */
6972         { &hf_infiniband_Notice_IsGeneric, {
6973                 "IsGeneric", "infiniband.notice.isgeneric",
6974                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6975         },
6976         { &hf_infiniband_Notice_Type, {
6977                 "Type", "infiniband.notice.type",
6978                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6979         },
6980         { &hf_infiniband_Notice_ProducerTypeVendorID, {
6981                 "ProducerTypeVendorID", "infiniband.notice.producertypevendorid",
6982                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6983         },
6984         { &hf_infiniband_Notice_TrapNumberDeviceID, {
6985                 "TrapNumberDeviceID", "infiniband.notice.trapnumberdeviceid",
6986                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6987         },
6988         { &hf_infiniband_Notice_IssuerLID, {
6989                 "IssuerLID", "infiniband.notice.issuerlid",
6990                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6991         },
6992         { &hf_infiniband_Notice_NoticeToggle, {
6993                 "NoticeToggle", "infiniband.notice.noticetoggle",
6994                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6995         },
6996         { &hf_infiniband_Notice_NoticeCount, {
6997                 "NoticeCount", "infiniband.notice.noticecount",
6998                 FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL}
6999         },
7000         { &hf_infiniband_Notice_DataDetails, {
7001                 "DataDetails", "infiniband.notice.datadetails",
7002                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7003         },
7004 #if 0
7005         { &hf_infiniband_Notice_IssuerGID, {
7006                 "IssuerGID", "infiniband.notice.issuergid",
7007                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7008         },
7009         { &hf_infiniband_Notice_ClassTrapSpecificData, {
7010                 "ClassTrapSpecificData", "infiniband.notice.classtrapspecificdata",
7011                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7012         },
7013 #endif
7014
7015         /* Traps 64,65,66,67 */
7016         { &hf_infiniband_Trap_GIDADDR, {
7017                 "GIDADDR", "infiniband.trap.gidaddr",
7018                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7019         },
7020         /* Traps 68,69 */
7021         { &hf_infiniband_Trap_COMP_MASK, {
7022                 "COMP_MASK", "infiniband.trap.comp_mask",
7023                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7024         },
7025         { &hf_infiniband_Trap_WAIT_FOR_REPATH, {
7026                 "WAIT_FOR_REPATH", "infiniband.trap.wait_for_repath",
7027                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
7028         },
7029 #if 0
7030         { &hf_infiniband_Trap_PATH_REC, {
7031                 "PATH_REC", "infiniband.trap.path_rec",
7032                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7033         },
7034 #endif
7035
7036         /* Trap 128 */
7037         { &hf_infiniband_Trap_LIDADDR, {
7038                 "LIDADDR", "infiniband.trap.lidaddr",
7039                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7040         },
7041
7042         /* Trap 129, 130, 131 */
7043         { &hf_infiniband_Trap_PORTNO, {
7044                 "PORTNO", "infiniband.trap.portno",
7045                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
7046         },
7047
7048         /* Trap 144 */
7049         { &hf_infiniband_Trap_OtherLocalChanges, {
7050                 "OtherLocalChanges", "infiniband.trap.otherlocalchanges",
7051                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
7052         },
7053         { &hf_infiniband_Trap_CAPABILITYMASK, {
7054                 "CAPABILITYMASK", "infiniband.trap.capabilitymask",
7055                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7056         },
7057         { &hf_infiniband_Trap_LinkSpeecEnabledChange, {
7058                 "LinkSpeecEnabledChange", "infiniband.trap.linkspeecenabledchange",
7059                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
7060         },
7061         { &hf_infiniband_Trap_LinkWidthEnabledChange, {
7062                 "LinkWidthEnabledChange", "infiniband.trap.linkwidthenabledchange",
7063                 FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL}
7064         },
7065         { &hf_infiniband_Trap_NodeDescriptionChange, {
7066                 "NodeDescriptionChange", "infiniband.trap.nodedescriptionchange",
7067                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
7068         },
7069
7070         /* Trap 145 */
7071         { &hf_infiniband_Trap_SYSTEMIMAGEGUID, {
7072                 "SYSTEMIMAGEGUID", "infiniband.trap.systemimageguid",
7073                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7074         },
7075
7076         /* Trap 256 */
7077         { &hf_infiniband_Trap_DRSLID, {
7078                 "DRSLID", "infiniband.trap.drslid",
7079                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7080         },
7081         { &hf_infiniband_Trap_METHOD, {
7082                 "METHOD", "infiniband.trap.method",
7083                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
7084         },
7085         { &hf_infiniband_Trap_ATTRIBUTEID, {
7086                 "ATTRIBUTEID", "infiniband.trap.attributeid",
7087                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7088         },
7089         { &hf_infiniband_Trap_ATTRIBUTEMODIFIER, {
7090                 "ATTRIBUTEMODIFIER", "infiniband.trap.attributemodifier",
7091                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7092         },
7093         { &hf_infiniband_Trap_MKEY, {
7094                 "MKEY", "infiniband.trap.mkey",
7095                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7096         },
7097         { &hf_infiniband_Trap_DRNotice, {
7098                 "DRNotice", "infiniband.trap.drnotice",
7099                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
7100         },
7101         { &hf_infiniband_Trap_DRPathTruncated, {
7102                 "DRPathTruncated", "infiniband.trap.drpathtruncated",
7103                 FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL}
7104         },
7105         { &hf_infiniband_Trap_DRHopCount, {
7106                 "DRHopCount", "infiniband.trap.drhopcount",
7107                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
7108         },
7109         { &hf_infiniband_Trap_DRNoticeReturnPath, {
7110                 "DRNoticeReturnPath", "infiniband.trap.drnoticereturnpath",
7111                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7112         },
7113
7114         /* Trap 257, 258 */
7115         { &hf_infiniband_Trap_LIDADDR1, {
7116                 "LIDADDR1", "infiniband.trap.lidaddr1",
7117                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7118         },
7119         { &hf_infiniband_Trap_LIDADDR2, {
7120                 "LIDADDR2", "infiniband.trap.lidaddr2",
7121                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7122         },
7123         { &hf_infiniband_Trap_KEY, {
7124                 "KEY", "infiniband.trap.key",
7125                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7126         },
7127         { &hf_infiniband_Trap_SL, {
7128                 "SL", "infiniband.trap.sl",
7129                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
7130         },
7131         { &hf_infiniband_Trap_QP1, {
7132                 "QP1", "infiniband.trap.qp1",
7133                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
7134         },
7135         { &hf_infiniband_Trap_QP2, {
7136                 "QP2", "infiniband.trap.qp2",
7137                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
7138         },
7139         { &hf_infiniband_Trap_GIDADDR1, {
7140                 "GIDADDR1", "infiniband.trap.gidaddr1",
7141                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7142         },
7143         { &hf_infiniband_Trap_GIDADDR2, {
7144                 "GIDADDR2", "infiniband.trap.gidaddr2",
7145                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7146         },
7147
7148         /* Trap 259 */
7149         { &hf_infiniband_Trap_DataValid, {
7150                 "DataValid", "infiniband.trap.datavalid",
7151                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7152         },
7153         { &hf_infiniband_Trap_PKEY, {
7154                 "PKEY", "infiniband.trap.pkey",
7155                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7156         },
7157         { &hf_infiniband_Trap_SWLIDADDR, {
7158                 "SWLIDADDR", "infiniband.trap.swlidaddr",
7159                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7160         },
7161         /* PortCounters in Performance class */
7162         { &hf_infiniband_PortCounters, {
7163                 "Port Counters (Performance Management MAD)", "infiniband.portcounters",
7164                 FT_NONE, BASE_NONE, NULL, 0x0,
7165                 "Performance class PortCounters packet", HFILL}
7166         },
7167         { &hf_infiniband_PortCounters_PortSelect, {
7168                 "PortSelect", "infiniband.portcounters.portselect",
7169                 FT_UINT8, BASE_HEX, NULL, 0x0,
7170                 "Selects the port that will be accessed", HFILL}
7171         },
7172         { &hf_infiniband_PortCounters_CounterSelect, {
7173                 "CounterSelect", "infiniband.portcounters.counterselect",
7174                 FT_UINT16, BASE_HEX, NULL, 0x0,
7175                 "When writing, selects which counters are affected by the operation", HFILL}
7176         },
7177         { &hf_infiniband_PortCounters_SymbolErrorCounter, {
7178                 "SymbolErrorCounter", "infiniband.portcounters.symbolerrorcounter",
7179                 FT_UINT16, BASE_DEC, NULL, 0x0,
7180                 "Total number of minor link errors", HFILL}
7181         },
7182         { &hf_infiniband_PortCounters_LinkErrorRecoveryCounter, {
7183                 "LinkErrorRecoveryCounter", "infiniband.portcounters.linkerrorrecoverycounter",
7184                 FT_UINT8, BASE_DEC, NULL, 0x0,
7185                 "Total number of times successfully completed link error recovery process", HFILL}
7186         },
7187         { &hf_infiniband_PortCounters_LinkDownedCounter, {
7188                 "LinkDownedCounter", "infiniband.portcounters.linkdownedcounter",
7189                 FT_UINT8, BASE_DEC, NULL, 0x0,
7190                 "Total number of times failed link error recovery process", HFILL}
7191         },
7192         { &hf_infiniband_PortCounters_PortRcvErrors, {
7193                 "PortRcvErrors", "infiniband.portcounters.portrcverrors",
7194                 FT_UINT16, BASE_DEC, NULL, 0x0,
7195                 "Total number of packets containing an error received", HFILL}
7196         },
7197         { &hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, {
7198                 "PortRcvRemotePhysicalErrors", "infiniband.portcounters.portrcvremotephysicalerrors",
7199                 FT_UINT16, BASE_DEC, NULL, 0x0,
7200                 "Total number of packets marked with EBP delimiter received", HFILL}
7201         },
7202         { &hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, {
7203                 "PortRcvSwitchRelayErrors", "infiniband.portcounters.portrcvswitchrelayerrors",
7204                 FT_UINT16, BASE_DEC, NULL, 0x0,
7205                 "Total number of packets discarded because they could not be forwarded by switch relay",
7206                 HFILL}
7207         },
7208         { &hf_infiniband_PortCounters_PortXmitDiscards, {
7209                 "PortXmitDiscards", "infiniband.portcounters.portxmitdiscards",
7210                 FT_UINT16, BASE_DEC, NULL, 0x0,
7211                 "Total number of outbound packets discarded", HFILL}
7212         },
7213         { &hf_infiniband_PortCounters_PortXmitConstraintErrors, {
7214                 "PortXmitConstraintErrors", "infiniband.portcounters.portxmitconstrainterrors",
7215                 FT_UINT8, BASE_DEC, NULL, 0x0,
7216                 "Total number of packets not transmitted from the switch physical port", HFILL}
7217         },
7218         { &hf_infiniband_PortCounters_PortRcvConstraintErrors, {
7219                 "PortRcvConstraintErrors", "infiniband.portcounters.portrcvconstrainterrors",
7220                 FT_UINT8, BASE_DEC, NULL, 0x0,
7221                 "Total number of packets received on the switch physical port that are discarded", HFILL}
7222         },
7223         { &hf_infiniband_PortCounters_LocalLinkIntegrityErrors, {
7224                 "LocalLinkIntegrityErrors", "infiniband.portcounters.locallinkintegrityerrors",
7225                 FT_UINT8, BASE_DEC, NULL, 0x0,
7226                 "The number of times the count of local physical errors exceeded the threshold specified by LocalPhyErrors",
7227                 HFILL}
7228         },
7229         { &hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, {
7230                 "ExcessiveBufferOverrunErrors", "infiniband.portcounters.excessivebufferoverrunerrors",
7231                 FT_UINT8, BASE_DEC, NULL, 0x0,
7232                 "The number of times that OverrunErrors consecutive flow control update periods occured",
7233                 HFILL}
7234         },
7235         { &hf_infiniband_PortCounters_VL15Dropped, {
7236                 "VL15Dropped", "infiniband.portcounters.vl15dropped",
7237                 FT_UINT16, BASE_DEC, NULL, 0x0,
7238                 "Number of incoming VL15 packets dropped", HFILL}
7239         },
7240         { &hf_infiniband_PortCounters_PortXmitData, {
7241                 "PortXmitData", "infiniband.portcounters.portxmitdata",
7242                 FT_UINT32, BASE_DEC, NULL, 0x0,
7243                 "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL}
7244         },
7245         { &hf_infiniband_PortCounters_PortRcvData, {
7246                 "PortRcvData", "infiniband.portcounters.portrcvdata",
7247                 FT_UINT32, BASE_DEC, NULL, 0x0,
7248                 "Total number of data octets, divided by 4, received on all VLs at the port", HFILL}
7249         },
7250         { &hf_infiniband_PortCounters_PortXmitPkts, {
7251                 "PortXmitPkts", "infiniband.portcounters.portxmitpkts",
7252                 FT_UINT32, BASE_DEC, NULL, 0x0,
7253                 "Total number of packets transmitted on all VLs from the port", HFILL}
7254         },
7255         { &hf_infiniband_PortCounters_PortRcvPkts, {
7256                 "PortRcvPkts", "infiniband.portcounters.portrcvpkts",
7257                 FT_UINT32, BASE_DEC, NULL, 0x0,
7258                 "Total number of packets received from all VLs on the port", HFILL}
7259         },
7260         /* PortCountersExtended in Performance class */
7261         { &hf_infiniband_PortCountersExt, {
7262                 "Port Counters Extended (Performance Management MAD)", "infiniband.portcounters_ext",
7263                 FT_NONE, BASE_NONE, NULL, 0x0,
7264                 "Performance class PortCountersExtended packet", HFILL}
7265         },
7266         { &hf_infiniband_PortCountersExt_PortSelect, {
7267                 "PortSelect", "infiniband.portcounters_ext.portselect",
7268                 FT_UINT8, BASE_HEX, NULL, 0x0,
7269                 "Selects the port that will be accessed", HFILL}
7270         },
7271         { &hf_infiniband_PortCountersExt_CounterSelect, {
7272                 "CounterSelect", "infiniband.portcounters_ext.counterselect",
7273                 FT_UINT16, BASE_HEX, NULL, 0x0,
7274                 "When writing, selects which counters are affected by the operation", HFILL}
7275         },
7276         { &hf_infiniband_PortCountersExt_PortXmitData, {
7277                 "PortXmitData", "infiniband.portcounters_ext.portxmitdata",
7278                 FT_UINT64, BASE_DEC, NULL, 0x0,
7279                 "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL}
7280         },
7281         { &hf_infiniband_PortCountersExt_PortRcvData, {
7282                 "PortRcvData", "infiniband.portcounters_ext.portrcvdata",
7283                 FT_UINT64, BASE_DEC, NULL, 0x0,
7284                 "Total number of data octets, divided by 4, received on all VLs at the port", HFILL}
7285         },
7286         { &hf_infiniband_PortCountersExt_PortXmitPkts, {
7287                 "PortXmitPkts", "infiniband.portcounters_ext.portxmitpkts",
7288                 FT_UINT64, BASE_DEC, NULL, 0x0,
7289                 "Total number of packets transmitted on all VLs from the port", HFILL}
7290         },
7291         { &hf_infiniband_PortCountersExt_PortRcvPkts, {
7292                 "PortRcvPkts", "infiniband.portcounters_ext.portrcvpkts",
7293                 FT_UINT64, BASE_DEC, NULL, 0x0,
7294                 "Total number of packets received from all VLs on the port", HFILL}
7295         },
7296         { &hf_infiniband_PortCountersExt_PortUnicastXmitPkts, {
7297                 "PortUnicastXmitPkts", "infiniband.portcounters_ext.portunicastxmitpkts",
7298                 FT_UINT64, BASE_DEC, NULL, 0x0,
7299                 "Total number of unicast packets transmitted on all VLs from the port", HFILL}
7300         },
7301         { &hf_infiniband_PortCountersExt_PortUnicastRcvPkts, {
7302                 "PortUnicastRcvPkts", "infiniband.portcounters_ext.portunicastrcvpkts",
7303                 FT_UINT64, BASE_DEC, NULL, 0x0,
7304                 "Total number of unicast packets received from all VLs on the port", HFILL}
7305         },
7306         { &hf_infiniband_PortCountersExt_PortMulticastXmitPkts, {
7307                 "PortMulticastXmitPkts", "infiniband.portcounters_ext.portmulticastxmitpkts",
7308                 FT_UINT64, BASE_DEC, NULL, 0x0,
7309                 "Total number of multicast packets transmitted on all VLs from the port", HFILL}
7310         },
7311         { &hf_infiniband_PortCountersExt_PortMulticastRcvPkts, {
7312                 "PortMulticastRcvPkts", "infiniband.portcounters_ext.portmulticastrcvpkts",
7313                 FT_UINT64, BASE_DEC, NULL, 0x0,
7314                 "Total number of multicast packets received from all VLs on the port", HFILL}
7315         }
7316     };
7317
7318     /* Array to hold expansion options between dissections */
7319     static gint *ett[] = {
7320     /*  &ett_infiniband,       */
7321         &ett_all_headers,
7322         &ett_lrh,
7323         &ett_grh,
7324         &ett_bth,
7325         &ett_rwh,
7326         &ett_rdeth,
7327         &ett_deth,
7328         &ett_reth,
7329         &ett_atomiceth,
7330         &ett_aeth,
7331         &ett_atomicacketh,
7332         &ett_immdt,
7333         &ett_ieth,
7334         &ett_payload,
7335         &ett_vendor,
7336         &ett_subn_lid_routed,
7337         &ett_subn_directed_route,
7338         &ett_subnadmin,
7339         &ett_cm,
7340         &ett_mad,
7341         &ett_rmpp,
7342         &ett_subm_attribute,
7343         &ett_suba_attribute,
7344         &ett_datadetails,
7345         &ett_noticestraps,
7346     /*  &ett_nodedesc,         */
7347     /*  &ett_nodeinfo,         */
7348     /*  &ett_switchinfo,       */
7349     /*  &ett_guidinfo,         */
7350     /*  &ett_portinfo,         */
7351         &ett_portinfo_capmask,
7352         &ett_pkeytable,
7353         &ett_sltovlmapping,
7354         &ett_vlarbitrationtable,
7355         &ett_linearforwardingtable,
7356         &ett_randomforwardingtable,
7357         &ett_multicastforwardingtable,
7358         &ett_sminfo,
7359         &ett_vendordiag,
7360         &ett_ledinfo,
7361         &ett_linkspeedwidthpairs,
7362         &ett_informinfo,
7363         &ett_linkrecord,
7364         &ett_servicerecord,
7365         &ett_pathrecord,
7366         &ett_mcmemberrecord,
7367         &ett_tracerecord,
7368         &ett_multipathrecord,
7369         &ett_serviceassocrecord,
7370         &ett_perfclass,
7371         &ett_eoib
7372     };
7373
7374     static hf_register_info hf_link[] = {
7375         { &hf_infiniband_link_op, {
7376                 "Operand", "infiniband_link.op",
7377                 FT_UINT16, BASE_DEC, VALS(Operand_Description), 0xF000, NULL, HFILL}
7378         },
7379         { &hf_infiniband_link_fctbs, {
7380                 "Flow Control Total Blocks Sent", "infiniband_link.fctbs",
7381                 FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL}
7382         },
7383         { &hf_infiniband_link_vl, {
7384                 "Virtual Lane", "infiniband_link.vl",
7385                 FT_UINT16, BASE_DEC, NULL, 0xF000, NULL, HFILL}
7386         },
7387         { &hf_infiniband_link_fccl, {
7388                 "Flow Control Credit Limit", "infiniband_link.fccl",
7389                 FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL}
7390         },
7391         { &hf_infiniband_link_lpcrc, {
7392                 "Link Packet CRC", "infiniband_link.lpcrc",
7393                 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL}
7394         }
7395     };
7396
7397
7398     static gint *ett_link_array[] = {
7399         &ett_link
7400     };
7401
7402     proto_infiniband = proto_register_protocol("InfiniBand", "InfiniBand", "infiniband");
7403     register_dissector("infiniband", dissect_infiniband, proto_infiniband);
7404
7405     proto_register_field_array(proto_infiniband, hf, array_length(hf));
7406     proto_register_subtree_array(ett, array_length(ett));
7407
7408     /* register the subdissector tables */
7409     register_heur_dissector_list("infiniband.payload", &heur_dissectors_payload);
7410     register_heur_dissector_list("infiniband.mad.cm.private", &heur_dissectors_cm_private);
7411
7412     /* register dissection preferences */
7413     infiniband_module = prefs_register_protocol(proto_infiniband, NULL);
7414
7415     prefs_register_bool_preference(infiniband_module, "identify_payload",
7416                                    "Attempt to identify and parse encapsulated IBA payloads",
7417                                    "When set, dissector will attempt to identify unknown IBA payloads "
7418                                    "as containing an encapsulated ethertype, and parse them accordingly",
7419                                    &pref_identify_iba_payload);
7420     prefs_register_bool_preference(infiniband_module, "dissect_eoib",
7421                                    "Attempt to identify and parse Mellanox EoIB packets",
7422                                    "When set, dissector will attempt to identify and parse "
7423                                    "Mellanox Ethernet-over-InfiniBand packets",
7424                                    &pref_dissect_eoib);
7425
7426     proto_infiniband_link = proto_register_protocol("InfiniBand Link", "InfiniBand Link", "infiniband_link");
7427     register_dissector("infiniband_link", dissect_infiniband_link, proto_infiniband_link);
7428
7429     proto_register_field_array(proto_infiniband_link, hf_link, array_length(hf_link));
7430     proto_register_subtree_array(ett_link_array, array_length(ett_link_array));
7431
7432     /* initialize the hash table */
7433     CM_context_table = g_hash_table_new_full(g_int64_hash, g_int64_equal,
7434                                              table_destroy_notify, table_destroy_notify);
7435 }
7436
7437 /* Reg Handoff.  Register dissectors we'll need for IPoIB and RoCE */
7438 void proto_reg_handoff_infiniband(void)
7439 {
7440     dissector_handle_t roce_handle;
7441
7442     ipv6_handle = find_dissector("ipv6");
7443     data_handle = find_dissector("data");
7444     eth_handle = find_dissector("eth");
7445     ethertype_dissector_table = find_dissector_table("ethertype");
7446
7447     /* create and announce an anonymous RoCE dissector */
7448     roce_handle = create_dissector_handle(dissect_roce, proto_infiniband);
7449     dissector_add_uint("ethertype", ETHERTYPE_ROCE, roce_handle);
7450 }