Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

packet-ipmi.h
1 /* packet-ipmi.h
2 * Definitions for IPMI dissection
3 * Copyright 2002-2008, Alexey Neyman, Pigeon Point Systems <avn@pigeonpoint.com>
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12 #ifndef __PACKET_IPMI_H__
13 #define __PACKET_IPMI_H__
14
15 #include <epan/expert.h>
16
17 /* IPMI definitions */
18
19 /* Max 32 netfn codes: 6 bits, of which 1 designates request/response */
20 #define IPMI_NETFN_MAX 32
21
22 /* IPMI Network Function supported values.
23 */
24 #define IPMI_CHASSIS_REQ 0x00 /* Chassis */
25 #define IPMI_BRIDGE_REQ 0x02 /* Bridge */
26 #define IPMI_SE_REQ 0x04 /* Sensor/Event */
27 #define IPMI_APP_REQ 0x06 /* Application */
28 #define IPMI_UPDATE_REQ 0x08 /* Firmware update */
29 #define IPMI_STORAGE_REQ 0x0a /* Storage */
30 #define IPMI_TRANSPORT_REQ 0x0c /* Transport */
31 #define IPMI_GROUP_REQ 0x2c /* Group */
32 #define IPMI_OEM_REQ 0x2e /* OEM */
33
34 /* Selector for dissecting OEM commands which do not carry OEM signatures.
35 * IPMI spec says these commands are to be specified by OEM and depend on
36 * the IANA number reported via Get Device ID. However, Wireshark has no
37 * means to guess that. Therefore, allow the user to select which OEM commands
38 * should be used. This applies to the following netFns: 0x08/0x09 (Update),
39 * 0x30..0x3f. Note that the commands which bear defining body signature
40 * (netFns 0x2c..0x2f) are registered with IPMI_OEM_NONE, as they can be
41 * recognized. */
42 enum {
43 IPMI_OEM_NONE = 0,
44 IPMI_OEM_PPS /* Pigeon Point Systems extensions */
45 };
46
47 /*
48 * Command context (environment).
49 */
50 enum {
51 IPMI_E_NONE, /* no surround environment */
52 IPMI_E_SENDMSG_RQ, /* encapsulated into Send Message request */
53 IPMI_E_SENDMSG_RS, /* encapsulated into Send Message response */
54 IPMI_E_GETMSG /* encapsulated into Get Message response */
55 };
56
57 /*
58 * Cached IPMI message header.
59 */
60 typedef struct {
61 guint8 context;
62 guint8 channel;
63 guint8 dir;
64 guint8 session;
65 guint8 rs_sa;
66 guint8 rs_lun;
67 guint8 netfn;
68 guint8 rq_sa;
69 guint8 rq_lun;
70 guint8 rq_seq;
71 guint8 cmd;
72 } ipmi_header_t;
73
74 /* Sub-parser */
75 typedef void (*ipmi_cmd_handler_t)(tvbuff_t *,
76 packet_info *, proto_tree *);
77
78 /* IPMI command structure. */
79 typedef struct {
80 guint32 cmd; /* Command number */
81 ipmi_cmd_handler_t parse_req; /* Request parser */
82 ipmi_cmd_handler_t parse_resp; /* Response parser */
83 const value_string *cs_cc; /* Command-specific completion codes */
84 const value_string *subfn; /* Subfunction codes */
85 const char *desc; /* Command description */
86 int flags; /* Command flags */
87 } ipmi_cmd_t;
88
89 /* Command flags */
90 #define CMD_CALLRQ 0x02 /* Call request handler early to cache data */
91
92 /* Get currently parsed message header */
93 const ipmi_header_t * ipmi_get_hdr(packet_info * pinfo);
94
95 /* Get completion code for currently parsed message */
96 guint8 ipmi_get_ccode(packet_info * pinfo);
97
98 /* Save request data for later use in response */
99 void ipmi_set_data(packet_info *pinfo, guint idx, guint32 data);
100
101 /* Get saved request data */
102 gboolean ipmi_get_data(packet_info *pinfo, guint idx, guint32 * data);
103
104 /* Top-level search structure: signatures (if any) + command table */
105 typedef struct ipmi_netfn_handler {
106 struct ipmi_netfn_handler *next;
107 const char *desc;
108 guint oem_selector;
109 const guint8 *sig;
110 ipmi_cmd_t *cmdtab;
111 guint32 cmdtablen;
112 } ipmi_netfn_t;
113
114 /* Stub parser. Use this to substitute for not-yet-written subparsers;
115 NULL in command table means 'no custom data in this request/response' */
116 void ipmi_notimpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
117 #define IPMI_TBD ipmi_notimpl, ipmi_notimpl
118
119 /* Add a Type/Length field to tree */
120 void ipmi_add_typelen(proto_tree *tree, int hf_string, int hf_type, int hf_length, tvbuff_t *tvb,
121 guint offs, gboolean is_fru);
122
123 /* Add Timestamp in IPMI format */
124 void ipmi_add_timestamp(proto_tree *tree, gint hf, tvbuff_t *tvb, guint offset);
125
126 /* GUID, IPMI style (fields reversed, little-endian) */
127 void ipmi_add_guid(proto_tree *tree, gint hf, tvbuff_t *tvb, guint offset);
128
129 /* Common format routines */
130 void ipmi_fmt_10ms_1based(gchar *, guint32);
131 void ipmi_fmt_500ms_0based(gchar *, guint32);
132 void ipmi_fmt_500ms_1based(gchar *, guint32);
133 void ipmi_fmt_1s_0based(gchar *, guint32);
134 void ipmi_fmt_1s_1based(gchar *, guint32);
135 void ipmi_fmt_2s_0based(gchar *, guint32);
136 void ipmi_fmt_5s_1based(gchar *, guint32);
137 void ipmi_fmt_version(gchar *, guint32);
138 void ipmi_fmt_channel(gchar *, guint32);
139 void ipmi_fmt_udpport(gchar *, guint32);
140 void ipmi_fmt_percent(gchar *, guint32);
141
142 /* Registrar for subparsers */
143 void ipmi_register_netfn_cmdtab(guint32 netfn, guint oem_selector,
144 const guint8 *sig, guint32 siglen, const char *desc,
145 ipmi_cmd_t *cmdtab, guint32 cmdtablen);
146
147 /* Lookup routines */
148 guint32 ipmi_getsiglen(guint32 netfn);
149 const char *ipmi_getnetfnname(guint32 netfn, ipmi_netfn_t *nf);
150 ipmi_netfn_t *ipmi_getnetfn(guint32 netfn, const guint8 *sig);
151 ipmi_cmd_t *ipmi_getcmd(ipmi_netfn_t *nf, guint32 cmd);
152 const char *ipmi_get_completion_code(guint8 completion, ipmi_cmd_t *cmd);
153
154 /* Used for sub-registrars (ipmi_*.c) */
155 extern gint proto_ipmi;
156
157 /* Main dissection routine */
158 #define IPMI_D_NONE 0x0001 /* Do not parse at all */
159 #define IPMI_D_SESSION_HANDLE 0x0002 /* Session handle */
160 #define IPMI_D_BROADCAST 0x0004 /* Check for broadcast message */
161 #define IPMI_D_TRG_SA 0x0008 /* Target slave addr is present */
162 #define IPMI_D_TMODE 0x0010 /* Bridged field instead of Rq LUN */
163 #define IPMI_D_NO_CKS 0x0020 /* Checksum bytes are not present */
164 #define IPMI_D_NO_RQ_SA 0x0040 /* RQ SA is not present */
165 #define IPMI_D_NO_SEQ 0x0080 /* RQ Seq is not present */
166
167 /* IPMI dissector argument */
168 typedef struct {
169 guint8 context;
170 guint8 channel;
171 guint8 flags;
172 } ipmi_dissect_arg_t;
173
174 int
175 do_dissect_ipmb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
176 gint hf_parent_item, gint ett_tree, ipmi_dissect_arg_t * arg);
177
178 #endif /* __PACKET_IPMI_H__ */
179
180 /*
181 * Editor modelines - http://www.wireshark.org/tools/modelines.html
182 *
183 * Local variables:
184 * c-basic-offset: 8
185 * tab-width: 8
186 * indent-tabs-mode: t
187 * End:
188 *
189 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
190 * :indentSize=8:tabSize=8:noTabs=false:
191 */
ipmi_cmd_t
Definition: packet-ipmi.h:79
_packet_info
Definition: packet_info.h:44
tvbuff
Definition: tvbuff-int.h:35
ipmi_netfn_handler
Definition: packet-ipmi.h:105
ipmi_header_t
Definition: packet-ipmi.h:60
ipmi_dissect_arg_t
Definition: packet-ipmi.h:168
_value_string
Definition: value_string.h:24
_proto_node
Definition: proto.h:759