2 * Definitions for IPMI dissection
3 * Copyright 2002-2008, Alexey Neyman, Pigeon Point Systems <avn@pigeonpoint.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef __PACKET_IPMI_H__
27 #define __PACKET_IPMI_H__
29 /* IPMI definitions */
31 /* Max 32 netfn codes: 6 bits, of which 1 designates request/response */
32 #define IPMI_NETFN_MAX 32
34 /* IPMI Network Function supported values.
36 #define IPMI_CHASSIS_REQ 0x00 /* Chassis */
37 #define IPMI_BRIDGE_REQ 0x02 /* Bridge */
38 #define IPMI_SE_REQ 0x04 /* Sensor/Event */
39 #define IPMI_APP_REQ 0x06 /* Application */
40 #define IPMI_UPDATE_REQ 0x08 /* Firmware update */
41 #define IPMI_STORAGE_REQ 0x0a /* Storage */
42 #define IPMI_TRANSPORT_REQ 0x0c /* Transport */
43 #define IPMI_GROUP_REQ 0x2c /* Group */
44 #define IPMI_OEM_REQ 0x2e /* OEM */
46 /* Selector for dissecting OEM commands which do not carry OEM signatures.
47 * IPMI spec says these commands are to be specified by OEM and depend on
48 * the IANA number reported via Get Device ID. However, Wireshark has no
49 * means to guess that. Therefore, allow the user to select which OEM commands
50 * should be used. This applies to the following netFns: 0x08/0x09 (Update),
51 * 0x30..0x3f. Note that the commands which bear defining body signature
52 * (netFns 0x2c..0x2f) are registered with IPMI_OEM_NONE, as they can be
56 IPMI_OEM_PPS
/* Pigeon Point Systems extensions */
59 /* IPMI header fields */
72 extern struct ipmi_header
*ipmi_current_hdr
;
75 typedef void (*ipmi_cmd_handler_t
)(tvbuff_t
*, packet_info
*, proto_tree
*);
77 /* IPMI command structure. */
79 guint32 cmd
; /* Command number */
80 ipmi_cmd_handler_t parse_req
; /* Request parser */
81 ipmi_cmd_handler_t parse_resp
; /* Response parser */
82 const value_string
*cs_cc
; /* Command-specific completion codes */
83 const value_string
*subfn
; /* Subfunction codes */
84 const char *desc
; /* Command description */
85 int flags
; /* Command flags */
89 #define CMD_MAYBROADCAST 0x01 /* Command can be broadcast over IPMB */
90 #define CMD_CALLRQ 0x02 /* Call request handler early to cache data */
91 #define CMD_NEWCONV 0x04 /* This command starts new conversation */
93 void ipmi_setsaveddata(guint idx
, guint32 val
);
94 gboolean
ipmi_getsaveddata(guint idx
, guint32
*val
);
96 /* Top-level search structure: signatures (if any) + command table */
97 typedef struct ipmi_netfn_handler
{
98 struct ipmi_netfn_handler
*next
;
106 /* Handy wrapper around decode_bitfield_value() */
107 char *ipmi_dcd8(guint32 val
, guint32 mask
);
109 /* Stub parser. Use this to substitute for not-yet-written subparsers;
110 NULL in command table means 'no custom data in this request/response' */
111 void ipmi_notimpl(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
);
112 #define IPMI_TBD ipmi_notimpl, ipmi_notimpl
114 /* Add a Type/Length field to tree */
115 void ipmi_add_typelen(proto_tree
*tree
, const char *desc
, tvbuff_t
*tvb
,
116 guint offs
, gboolean is_fru
);
118 /* Add Timestamp in IPMI format */
119 void ipmi_add_timestamp(proto_tree
*tree
, gint hf
, tvbuff_t
*tvb
, guint offset
);
121 /* GUID, IPMI style (fields reversed, little-endian) */
122 void ipmi_add_guid(proto_tree
*tree
, gint hf
, tvbuff_t
*tvb
, guint offset
);
124 /* Common format routines */
125 void ipmi_fmt_10ms_1based(gchar
*, guint32
);
126 void ipmi_fmt_500ms_0based(gchar
*, guint32
);
127 void ipmi_fmt_500ms_1based(gchar
*, guint32
);
128 void ipmi_fmt_1s_0based(gchar
*, guint32
);
129 void ipmi_fmt_1s_1based(gchar
*, guint32
);
130 void ipmi_fmt_2s_0based(gchar
*, guint32
);
131 void ipmi_fmt_5s_1based(gchar
*, guint32
);
132 void ipmi_fmt_version(gchar
*, guint32
);
133 void ipmi_fmt_channel(gchar
*, guint32
);
134 void ipmi_fmt_udpport(gchar
*, guint32
);
135 void ipmi_fmt_percent(gchar
*, guint32
);
137 /* Registrar for subparsers */
138 void ipmi_register_netfn_cmdtab(guint32 netfn
, guint oem_selector
,
139 const guint8
*sig
, guint32 siglen
, const char *desc
,
140 ipmi_cmd_t
*cmdtab
, guint32 cmdtablen
);
142 /* Lookup routines */
143 guint32
ipmi_getsiglen(guint32 netfn
);
144 const char *ipmi_getnetfnname(guint32 netfn
, ipmi_netfn_t
*nf
);
145 ipmi_netfn_t
*ipmi_getnetfn(guint32 netfn
, const guint8
*sig
);
146 ipmi_cmd_t
*ipmi_getcmd(ipmi_netfn_t
*nf
, guint32 cmd
);
147 const char *ipmi_get_completion_code(guint8 completion
, ipmi_cmd_t
*cmd
);
149 /* Sub-registrars (ipmi_*.c) */
150 void ipmi_register_app(int proto
);
151 void ipmi_register_bridge(int proto
);
152 void ipmi_register_chassis(int proto
);
153 void ipmi_register_picmg(int proto
);
154 void ipmi_register_pps(int proto
);
155 void ipmi_register_se(int proto
);
156 void ipmi_register_storage(int proto
);
157 void ipmi_register_transport(int proto
);
158 void ipmi_register_update(int proto
);
160 /* Main dissection routine */
161 #define IPMI_D_NONE 0x0001 /* Do not parse at all */
162 #define IPMI_D_SESSION_HANDLE 0x0002 /* Session handle */
163 #define IPMI_D_BROADCAST 0x0004 /* Check for broadcast message */
164 #define IPMI_D_TRG_SA 0x0008 /* Target slave addr is present */
170 gchar info
[ITEM_LABEL_LENGTH
];
171 void *arg
; /* Argument passed to callbacks */
173 /* Extra methods for requests that contain embedded commands */
174 struct ipmi_header
*(*getmoreheaders
)(struct ipmi_header
*base
, void *arg
, guint i
);
175 int (*whichresponse
)(struct ipmi_header
*hdr
, struct ipmi_reqresp
*rr
);
176 int (*otheridx
)(struct ipmi_header
*hdr
);
177 } ipmi_dissect_format_t
;
179 int ipmi_guess_dissect_flags(tvbuff_t
*tvb
);
180 void ipmi_do_dissect(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, ipmi_dissect_format_t
*dfmt
);
182 struct ipmi_header
*ipmi_sendmsg_getheaders(struct ipmi_header
*base
, void *arg
, guint i
);
183 int ipmi_sendmsg_whichresponse(struct ipmi_header
*hdr
, struct ipmi_reqresp
*rr
);
184 int ipmi_sendmsg_otheridx(struct ipmi_header
*hdr
);