| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
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 uint8_t context;
62 uint8_t channel;
63 uint8_t dir;
64 uint8_t session;
65 uint8_t rs_sa;
66 uint8_t rs_lun;
67 uint8_t netfn;
68 uint8_t rq_sa;
69 uint8_t rq_lun;
70 uint8_t rq_seq;
71 uint8_t 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 uint32_t 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 */
96uint8_t ipmi_get_ccode(packet_info * pinfo);
97
98/* Save request data for later use in response */
99 void ipmi_set_data(packet_info *pinfo, unsigned idx, uint32_t data);
100
101/* Get saved request data */
102 bool ipmi_get_data(packet_info *pinfo, unsigned idx, uint32_t * 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 unsigned oem_selector;
109 const uint8_t *sig;
110 const ipmi_cmd_t *cmdtab;
111 uint32_t 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(packet_info *pinfo, proto_tree *tree, int hf_string, int hf_type, int hf_length, tvbuff_t *tvb,
121 unsigned offs, bool is_fru);
122
123/* Add Timestamp in IPMI format */
124 void ipmi_add_timestamp(packet_info *pinfo, proto_tree *tree, int hf, tvbuff_t *tvb, unsigned offset);
125
126/* GUID, IPMI style (fields reversed, little-endian) */
127 void ipmi_add_guid(proto_tree *tree, int hf, tvbuff_t *tvb, unsigned offset);
128
129/* Common format routines */
130 void ipmi_fmt_10ms_1based(char *, uint32_t);
131 void ipmi_fmt_500ms_0based(char *, uint32_t);
132 void ipmi_fmt_500ms_1based(char *, uint32_t);
133 void ipmi_fmt_1s_0based(char *, uint32_t);
134 void ipmi_fmt_1s_1based(char *, uint32_t);
135 void ipmi_fmt_2s_0based(char *, uint32_t);
136 void ipmi_fmt_5s_1based(char *, uint32_t);
137 void ipmi_fmt_version(char *, uint32_t);
138 void ipmi_fmt_channel(char *, uint32_t);
139 void ipmi_fmt_udpport(char *, uint32_t);
140 void ipmi_fmt_percent(char *, uint32_t);
141
142/* Registrar for subparsers */
143 void ipmi_register_netfn_cmdtab(uint32_t netfn, unsigned oem_selector,
144 const uint8_t *sig, uint32_t siglen, const char *desc,
145 const ipmi_cmd_t *cmdtab, uint32_t cmdtablen);
146
147/* Lookup routines */
148uint32_t ipmi_getsiglen(uint32_t netfn);
149 const char *ipmi_getnetfnname(wmem_allocator_t *pool, uint32_t netfn, ipmi_netfn_t *nf);
150 ipmi_netfn_t *ipmi_getnetfn(uint32_t netfn, const uint8_t *sig);
151 const ipmi_cmd_t *ipmi_getcmd(ipmi_netfn_t *nf, uint32_t cmd);
152 const char *ipmi_get_completion_code(uint8_t completion, const ipmi_cmd_t *cmd);
153
154/* Used for sub-registrars (ipmi_*.c) */
155 extern int 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 uint8_t context;
170 uint8_t channel;
171 uint8_t flags;
172} ipmi_dissect_arg_t;
173
174 int
175do_dissect_ipmb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
176 int hf_parent_item, int ett_tree, ipmi_dissect_arg_t * arg);
177
178#endif /* __PACKET_IPMI_H__ */
179
180/*
181 * Editor modelines - https://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 */
expert.h
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_value_string
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
ipmi_cmd_t
Definition packet-ipmi.h:79
ipmi_dissect_arg_t
Definition packet-ipmi.h:168
ipmi_header_t
Definition packet-ipmi.h:60
ipmi_netfn_handler
Definition packet-ipmi.h:105
tvbuff
Definition tvbuff-int.h:35