forked from maoali/freeipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipmi_monitoring_defs.h
228 lines (190 loc) · 8.63 KB
/
ipmi_monitoring_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*****************************************************************************\
* $Id: ipmi_monitoring_defs.h,v 1.41 2010-07-22 21:49:00 chu11 Exp $
*****************************************************************************
* Copyright (C) 2007-2015 Lawrence Livermore National Security, LLC.
* Copyright (C) 2006-2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Albert Chu <[email protected]>
* UCRL-CODE-222073
*
* This file is part of Ipmimonitoring, an IPMI sensor monitoring
* library. For details, see http://www.llnl.gov/linux/.
*
* Ipmimonitoring is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* Ipmimonitoring is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with Ipmimonitoring. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/
#ifndef IPMI_MONITORING_DEFS_H
#define IPMI_MONITORING_DEFS_H
#if HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <stdint.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <limits.h> /* MAXHOSTNAMELEN */
#ifdef HAVE_NETDB_H
#include <netdb.h> /* MAXHOSTNAMELEN Solaris */
#endif /* HAVE_NETDB_H */
#include <freeipmi/freeipmi.h>
#include "list.h"
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif /* MAXHOSTNAMELEN */
#ifndef MAXPATHLEN
#define MAXPATHLEN 4096
#endif /* MAXPATHLEN */
/* +1 to avoid gcc warnings */
#define IPMI_MONITORING_SENSOR_TYPE_VALID(__val) \
(((((__val) + 1) >= (IPMI_MONITORING_SENSOR_TYPE_RESERVED + 1) \
&& ((__val) - 1) <= (IPMI_MONITORING_SENSOR_TYPE_OEM_MAX - 1)) \
|| ((__val) == IPMI_MONITORING_SENSOR_TYPE_UNKNOWN)) ? 1 : 0)
#define IPMI_MONITORING_SENSOR_TYPE_INPUT_VALID(__val) \
((((__val) + 1) >= (IPMI_MONITORING_SENSOR_TYPE_TEMPERATURE + 1) \
&& ((__val) - 1) <= (IPMI_MONITORING_SENSOR_TYPE_OEM_MAX - 1)) ? 1 : 0)
#define IPMI_MONITORING_STATE_VALID(__val) \
(((__val) == IPMI_MONITORING_STATE_NOMINAL \
|| (__val) == IPMI_MONITORING_STATE_WARNING \
|| (__val) == IPMI_MONITORING_STATE_CRITICAL \
|| (__val) == IPMI_MONITORING_STATE_UNKNOWN) ? 1 : 0)
/* +1 to avoid gcc warnings */
#define IPMI_MONITORING_SENSOR_UNITS_VALID(__val) \
((((__val) + 1) >= (IPMI_MONITORING_SENSOR_UNITS_NONE + 1) \
&& (__val) <= IPMI_MONITORING_SENSOR_UNITS_UNKNOWN) ? 1 : 0)
#define IPMI_MONITORING_SENSOR_READING_TYPE_VALID(__val) \
(((__val) == IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL \
|| (__val) == IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32 \
|| (__val) == IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE \
|| (__val) == IPMI_MONITORING_SENSOR_READING_TYPE_UNKNOWN) ? 1 : 0)
/* +1 to avoid gcc warnings */
#define IPMI_MONITORING_SENSOR_BITMASK_TYPE_VALID(__val) \
(((((__val) + 1) >= (IPMI_MONITORING_SENSOR_BITMASK_TYPE_THRESHOLD + 1) \
&& (__val) <= IPMI_MONITORING_SENSOR_BITMASK_TYPE_FRU_STATE) \
|| (__val) == IPMI_MONITORING_SENSOR_BITMASK_TYPE_OEM \
|| (__val) == IPMI_MONITORING_SENSOR_BITMASK_TYPE_UNKNOWN) ? 1 : 0)
#define IPMI_MONITORING_MAX_USER_NAME_LENGTH IPMI_MAX_USER_NAME_LENGTH
#define IPMI_MONITORING_MAX_PASSWORD_LENGTH IPMI_MAX_1_5_PASSWORD_LENGTH
#define IPMI_MONITORING_PRIVILEGE_LEVEL_VALID(__val) \
(((__val) == IPMI_MONITORING_PRIVILEGE_LEVEL_USER \
|| (__val) == IPMI_MONITORING_PRIVILEGE_LEVEL_OPERATOR \
|| (__val) == IPMI_MONITORING_PRIVILEGE_LEVEL_ADMIN) ? 1 : 0)
#define IPMI_MONITORING_AUTHENTICATION_TYPE_VALID(__val) \
(((__val) == IPMI_MONITORING_AUTHENTICATION_TYPE_NONE \
|| (__val) == IPMI_MONITORING_AUTHENTICATION_TYPE_STRAIGHT_PASSWORD_KEY \
|| (__val) == IPMI_MONITORING_AUTHENTICATION_TYPE_MD2 \
|| (__val) == IPMI_MONITORING_AUTHENTICATION_TYPE_MD5) ? 1 : 0)
#define IPMI_MONITORING_FLAGS_MASK \
(IPMI_MONITORING_FLAGS_NONE \
| IPMI_MONITORING_FLAGS_DEBUG \
| IPMI_MONITORING_FLAGS_DEBUG_IPMI_PACKETS \
| IPMI_MONITORING_FLAGS_LOCK_MEMORY)
#define IPMI_MONITORING_SEL_FLAGS_MASK \
(IPMI_MONITORING_SEL_FLAGS_REREAD_SDR_CACHE \
| IPMI_MONITORING_SEL_FLAGS_INTERPRET_OEM_DATA \
| IPMI_MONITORING_SEL_FLAGS_ASSUME_SYSTEM_EVENT_RECORD \
| IPMI_MONITORING_SEL_FLAGS_ENTITY_SENSOR_NAMES \
| IPMI_MONITORING_SEL_FLAGS_ASSUME_MAX_SDR_RECORD_COUNT)
#define IPMI_MONITORING_SENSOR_READING_FLAGS_MASK \
(IPMI_MONITORING_SENSOR_READING_FLAGS_REREAD_SDR_CACHE \
| IPMI_MONITORING_SENSOR_READING_FLAGS_IGNORE_NON_INTERPRETABLE_SENSORS \
| IPMI_MONITORING_SENSOR_READING_FLAGS_BRIDGE_SENSORS \
| IPMI_MONITORING_SENSOR_READING_FLAGS_INTERPRET_OEM_DATA \
| IPMI_MONITORING_SENSOR_READING_FLAGS_SHARED_SENSORS \
| IPMI_MONITORING_SENSOR_READING_FLAGS_DISCRETE_READING \
| IPMI_MONITORING_SENSOR_READING_FLAGS_IGNORE_SCANNING_DISABLED \
| IPMI_MONITORING_SENSOR_READING_FLAGS_ASSUME_BMC_OWNER \
| IPMI_MONITORING_SENSOR_READING_FLAGS_ENTITY_SENSOR_NAMES \
| IPMI_MONITORING_SENSOR_READING_FLAGS_ASSUME_MAX_SDR_RECORD_COUNT)
#define IPMI_MONITORING_AUTHENTICATION_TYPE_DEFAULT IPMI_AUTHENTICATION_TYPE_MD5
#define IPMI_MONITORING_PRIVILEGE_LEVEL_DEFAULT IPMI_PRIVILEGE_LEVEL_USER
#define IPMI_MONITORING_SESSION_TIMEOUT_LENGTH_DEFAULT 20000
#define IPMI_MONITORING_RETRANSMISSION_TIMEOUT_LENGTH_DEFAULT 500
#define IPMI_MONITORING_MAX_SENSOR_NAME_LENGTH 32
#define IPMI_MONITORING_OEM_DATA_MAX 13
#define IPMI_MONITORING_MAGIC 0xABCD9876
#define IPMI_MONITORING_PACKET_BUFLEN 1024
struct ipmi_monitoring_sel_record {
/* for all records */
int record_id;
int record_type;
int record_type_class;
int sel_state;
/* for timestamped records */
unsigned int timestamp;
/* for system event records */
int sensor_type;
int sensor_number;
char sensor_name[IPMI_MONITORING_MAX_SENSOR_NAME_LENGTH + 1];
int event_direction;
int event_offset_type;
int event_offset;
char *event_offset_string;
int event_type_code;
uint8_t event_data1;
uint8_t event_data2;
uint8_t event_data3;
/* for oem timestamped records */
int manufacturer_id;
/* for oem timestamped & non-timestamped records */
uint8_t oem_data[IPMI_MONITORING_OEM_DATA_MAX];
unsigned int oem_data_len;
};
struct ipmi_monitoring_sensor_reading {
int record_id;
int sensor_number;
int sensor_type;
char sensor_name[IPMI_MONITORING_MAX_SENSOR_NAME_LENGTH + 1];
int sensor_state;
int sensor_units;
int sensor_reading_type;
int sensor_bitmask_type;
int sensor_bitmask;
char **sensor_bitmask_strings;
union {
uint8_t bool_val;
uint32_t integer_val;
double double_val;
} sensor_reading;
int event_reading_type_code;
};
struct ipmi_monitoring_ctx {
uint32_t magic;
int errnum;
/* initialize this in ctx create */
ipmi_interpret_ctx_t interpret_ctx;
char sdr_cache_directory[MAXPATHLEN+1];
int sdr_cache_directory_set;
char sdr_cache_filename_format[MAXPATHLEN+1];
int sdr_cache_filename_format_set;
/* for use by both sel and sensor codepath */
uint32_t manufacturer_id;
uint16_t product_id;
/* for use by both sel and sensor codepath */
ipmi_sdr_ctx_t sdr_ctx;
ipmi_ctx_t ipmi_ctx;
Ipmi_Monitoring_Callback callback;
void *callback_data;
/* for sel codepath */
ipmi_sel_ctx_t sel_parse_ctx;
List sel_records;
ListIterator sel_records_itr;
struct ipmi_monitoring_sel_record *current_sel_record;
struct ipmi_monitoring_sel_record *callback_sel_record;
/* for sensor codepath */
ipmi_sensor_read_ctx_t sensor_read_ctx;
List sensor_readings;
ListIterator sensor_readings_itr;
struct ipmi_monitoring_sensor_reading *current_sensor_reading;
struct ipmi_monitoring_sensor_reading *callback_sensor_reading;
};
#endif /* IPMI_MONITORING_DEFS_H */