1 /*
2  * Copyright (C) 2003-2015 FreeIPMI Core Team
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 
19 #ifndef TOOL_CONFIG_FILE_COMMON_H
20 #define TOOL_CONFIG_FILE_COMMON_H
21 
22 #if HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "tool-cmdline-common.h"
27 #include "conffile.h"
28 
29 #define CONFIG_FILE_NONE        0x00
30 #define CONFIG_FILE_INBAND      0x01
31 #define CONFIG_FILE_OUTOFBAND   0x02
32 #define CONFIG_FILE_SDR         0x04
33 #define CONFIG_FILE_TIME        0x08
34 #define CONFIG_FILE_HOSTRANGE   0x10
35 
36 #define CONFIG_FILE_TOOL_NONE                0x00000000
37 #define CONFIG_FILE_TOOL_BMC_DEVICE          0x00000001
38 #define CONFIG_FILE_TOOL_BMC_INFO            0x00000002
39 #define CONFIG_FILE_TOOL_BMC_WATCHDOG        0x00000004
40 #define CONFIG_FILE_TOOL_IPMI_CHASSIS        0x00000008
41 #define CONFIG_FILE_TOOL_IPMI_CONFIG         0x00000010
42 #define CONFIG_FILE_TOOL_IPMI_DCMI           0x00000020
43 #define CONFIG_FILE_TOOL_IPMI_FRU            0x00000040
44 #define CONFIG_FILE_TOOL_IPMI_OEM            0x00000080
45 #define CONFIG_FILE_TOOL_IPMI_PET            0x00000100
46 #define CONFIG_FILE_TOOL_IPMI_RAW            0x00000200
47 #define CONFIG_FILE_TOOL_IPMI_SEL            0x00000400
48 #define CONFIG_FILE_TOOL_IPMI_SENSORS        0x00000800
49 #define CONFIG_FILE_TOOL_IPMICONSOLE         0x00001000
50 #define CONFIG_FILE_TOOL_IPMIPOWER           0x00002000
51 #define CONFIG_FILE_TOOL_IPMISELD            0x00004000
52 
53 /* achu:
54  *
55  * The stack on cygwin is smaller than on unixes, and the ability for
56  * me to get a bigger stack in cygwin is difficult.  The normal unix
57  * ways (i.e. ulimit -s unlimited) don't work.  Some posts online
58  * indicate it's b/c of the way windows works with stack limits.
59  *
60  * So we're just going to use smaller values to deal with the problem.
61  */
62 #ifdef __CYGWIN__
63 #define CONFIG_FILE_MAX_SENSOR_RECORD_IDS           128
64 #define CONFIG_FILE_MAX_SENSOR_TYPES                16
65 #else /* !__CYGWIN__ */
66 #if 0
67 /* record id is 16 bits - 65536 */
68 #define CONFIG_FILE_MAX_SENSOR_RECORD_IDS           65536
69 #define CONFIG_FILE_MAX_SENSOR_TYPES                256
70 #else  /* !0 */
71 /* achu: pick more reasonable limits than the theoretical maxes */
72 #define CONFIG_FILE_MAX_SENSOR_RECORD_IDS           4096
73 #define CONFIG_FILE_MAX_SENSOR_TYPES                128
74 #endif  /* !0 */
75 #endif /* !__CYGWIN__ */
76 #define CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH  256
77 
78 struct config_file_data_bmc_info
79 {
80   int interpret_oem_data;
81   int interpret_oem_data_count;
82 };
83 
84 struct config_file_data_bmc_watchdog
85 {
86   char *logfile;                /* deprecated */
87   int logfile_count;            /* deprecated */
88   int verbose_logging;
89   int verbose_logging_count;
90   int no_logging;
91   int no_logging_count;
92 };
93 
94 struct config_file_data_ipmi_config
95 {
96   unsigned int verbose_count;
97   int verbose_count_count;
98 };
99 
100 struct config_file_data_ipmi_dcmi
101 {
102   int interpret_oem_data;
103   int interpret_oem_data_count;
104 };
105 
106 struct config_file_data_ipmi_fru
107 {
108   unsigned int verbose_count;
109   int verbose_count_count;
110   int skip_checks;              /* legacy - parse for backwards compatability */
111   int skip_checks_count;        /* legacy - parse for backwards compatability */
112   int bridge_fru;
113   int bridge_fru_count;
114   int interpret_oem_data;
115   int interpret_oem_data_count;
116 };
117 
118 struct config_file_data_ipmi_oem
119 {
120   unsigned int verbose_count;
121   int verbose_count_count;
122 };
123 
124 struct config_file_data_ipmi_pet
125 {
126   unsigned int verbose_count;
127   int verbose_count_count;
128   int output_event_severity;
129   int output_event_severity_count;
130   int output_event_state;
131   int output_event_state_count;
132   char *event_state_config_file;
133   int event_state_config_file_count;
134   int interpret_oem_data;
135   int interpret_oem_data_count;
136   int entity_sensor_names;
137   int entity_sensor_names_count;
138   int no_sensor_type_output;
139   int no_sensor_type_output_count;
140   int comma_separated_output;
141   int comma_separated_output_count;
142   int no_header_output;
143   int no_header_output_count;
144   int non_abbreviated_units;
145   int non_abbreviated_units_count;
146 };
147 
148 struct config_file_data_ipmi_sel
149 {
150   unsigned int verbose_count;
151   int verbose_count_count;
152   char sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
153   unsigned int sensor_types_length;
154   int sensor_types_count;
155   char exclude_sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
156   unsigned int exclude_sensor_types_length;
157   int exclude_sensor_types_count;
158   int system_event_only;
159   int system_event_only_count;
160   int oem_event_only;
161   int oem_event_only_count;
162   int output_manufacturer_id;
163   int output_manufacturer_id_count;
164   int output_event_state;
165   int output_event_state_count;
166   char *event_state_config_file;
167   int event_state_config_file_count;
168   int assume_system_event_records; /* legacy - parse for backwards compatability */
169   int assume_system_event_records_count; /* legacy - parse for backwards compatability */
170   int interpret_oem_data;
171   int interpret_oem_data_count;
172   int output_oem_event_strings;
173   int output_oem_event_strings_count;
174   int entity_sensor_names;
175   int entity_sensor_names_count;
176   int no_sensor_type_output;
177   int no_sensor_type_output_count;
178   int comma_separated_output;
179   int comma_separated_output_count;
180   int no_header_output;
181   int no_header_output_count;
182   int non_abbreviated_units;
183   int non_abbreviated_units_count;
184   int legacy_output;
185   int legacy_output_count;
186 };
187 
188 struct config_file_data_ipmi_sensors
189 {
190   unsigned int verbose_count;
191   int verbose_count_count;
192   int quiet_readings;
193   int quiet_readings_count;
194   unsigned int record_ids[CONFIG_FILE_MAX_SENSOR_RECORD_IDS];
195   unsigned int record_ids_length;
196   int record_ids_count;
197   unsigned int exclude_record_ids[CONFIG_FILE_MAX_SENSOR_RECORD_IDS];
198   unsigned int exclude_record_ids_length;
199   int exclude_record_ids_count;
200   char sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
201   unsigned int sensor_types_length;
202   int sensor_types_count;
203   char exclude_sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
204   unsigned int exclude_sensor_types_length;
205   int exclude_sensor_types_count;
206   int bridge_sensors;
207   int bridge_sensors_count;
208   int shared_sensors;
209   int shared_sensors_count;
210   int interpret_oem_data;
211   int interpret_oem_data_count;
212   int ignore_not_available_sensors;
213   int ignore_not_available_sensors_count;
214   int ignore_unrecognized_events;
215   int ignore_unrecognized_events_count;
216   int entity_sensor_names;
217   int entity_sensor_names_count;
218   int output_event_bitmask;
219   int output_event_bitmask_count;
220   int output_sensor_state;
221   int output_sensor_state_count;
222   char *sensor_state_config_file;
223   int sensor_state_config_file_count;
224   int output_sensor_thresholds;
225   int output_sensor_thresholds_count;
226   int no_sensor_type_output;
227   int no_sensor_type_output_count;
228   int comma_separated_output_count;
229   int comma_separated_output;
230   int no_header_output;
231   int no_header_output_count;
232   int non_abbreviated_units;
233   int non_abbreviated_units_count;
234   int legacy_output;
235   int legacy_output_count;
236   int ipmimonitoring_legacy_output;
237   int ipmimonitoring_legacy_output_count;
238 };
239 
240 struct config_file_data_ipmiconsole
241 {
242   char escape_char;
243   int escape_char_count;
244   int dont_steal;
245   int dont_steal_count;
246   int serial_keepalive;
247   int serial_keepalive_count;
248   int serial_keepalive_empty;
249   int serial_keepalive_empty_count;
250   int sol_payload_instance;
251   int sol_payload_instance_count;
252   int deactivate_all_instances;
253   int deactivate_all_instances_count;
254   int lock_memory;
255   int lock_memory_count;
256 };
257 
258 struct config_file_data_ipmipower
259 {
260   int on_if_off;
261   int on_if_off_count;
262   int wait_until_on;
263   int wait_until_on_count;
264   int wait_until_off;
265   int wait_until_off_count;
266   /* Parse string and let ipmipower determine if it is valid */
267   char *oem_power_type_str;
268   int oem_power_type_str_count;
269 
270   unsigned int retransmission_wait_timeout;
271   int retransmission_wait_timeout_count;
272   unsigned int retransmission_backoff_count;
273   int retransmission_backoff_count_count;
274   unsigned int ping_interval;
275   int ping_interval_count;
276   unsigned int ping_timeout;
277   int ping_timeout_count;
278   unsigned int ping_packet_count;
279   int ping_packet_count_count;
280   unsigned int ping_percent;
281   int ping_percent_count;
282   unsigned int ping_consec_count;
283   int ping_consec_count_count;
284 };
285 
286 struct config_file_data_ipmiseld
287 {
288   char *hostname;
289   int hostname_count;
290   unsigned int verbose_count;
291   int verbose_count_count;
292   char sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
293   unsigned int sensor_types_length;
294   int sensor_types_count;
295   char exclude_sensor_types[CONFIG_FILE_MAX_SENSOR_TYPES][CONFIG_FILE_MAX_SENSOR_TYPES_STRING_LENGTH+1];
296   unsigned int exclude_sensor_types_length;
297   int exclude_sensor_types_count;
298   int system_event_only;
299   int system_event_only_count;
300   int oem_event_only;
301   int oem_event_only_count;
302   char *event_state_config_file;
303   int event_state_config_file_count;
304   int interpret_oem_data;
305   int interpret_oem_data_count;
306   int output_oem_event_strings;
307   int output_oem_event_strings_count;
308   int entity_sensor_names;
309   int entity_sensor_names_count;
310   int non_abbreviated_units;
311   int non_abbreviated_units_count;
312   char *event_state_filter_str;
313   int event_state_filter_str_count;
314   unsigned int warning_threshold;
315   int warning_threshold_count;
316   unsigned int clear_threshold;
317   int clear_threshold_count;
318   char *system_event_format_str;
319   int system_event_format_str_count;
320   char *oem_timestamped_event_format_str;
321   int oem_timestamped_event_format_str_count;
322   char *oem_non_timestamped_event_format_str;
323   int oem_non_timestamped_event_format_str_count;
324   unsigned int poll_interval;
325   int poll_interval_count;
326   char *log_facility_str;
327   int log_facility_str_count;
328   char *log_priority_str;
329   int log_priority_str_count;
330   char *cache_directory;
331   int cache_directory_count;
332   int ignore_sdr;
333   int ignore_sdr_count;
334   int re_download_sdr;
335   int re_download_sdr_count;
336   int clear_sel;
337   int clear_sel_count;
338   unsigned int threadpool_count;
339   int threadpool_count_count;
340 };
341 
342 int config_file_parse (const char *filename,
343                        int no_error_if_not_found,
344                        struct common_cmd_args *common_args,
345                        unsigned int support,
346                        unsigned int tool_support,
347                        void *tool_data);
348 
349 #endif /* TOOL_CONFIG_FILE_COMMON_H */
350