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 /* file is named ipmi-sel_.h to differentiate itself from the
20  * library ipmi-sel.h.
21  *
22  * I am scared of the portability of the #include_next directive, so
23  * that's why I'm doing it this way.
24  */
25 
26 /* file is "ipmi-sel_.h", so double underscore */
27 
28 #ifndef IPMI_SEL__H
29 #define IPMI_SEL__H
30 
31 #include <freeipmi/freeipmi.h>
32 
33 #include "tool-cmdline-common.h"
34 #include "tool-oem-common.h"
35 #include "tool-sensor-common.h"
36 #include "pstdout.h"
37 
38 #define IPMI_SEL_MAX_RECORD 4096
39 
40 enum ipmi_sel_argp_option_keys
41   {
42     VERBOSE_KEY = 'v',
43     INFO_KEY = 'i',
44     DISPLAY_KEY = 160,
45     EXCLUDE_DISPLAY_KEY = 161,
46     DISPLAY_RANGE_KEY = 162,
47     EXCLUDE_DISPLAY_RANGE_KEY = 163,
48     DATE_RANGE_KEY = 164,
49     EXCLUDE_DATE_RANGE_KEY = 165,
50     SENSOR_TYPES_KEY = 't',
51     EXCLUDE_SENSOR_TYPES_KEY = 'T',
52     LIST_SENSOR_TYPES_KEY = 'L',
53     TAIL_KEY = 166,
54     CLEAR_KEY = 167,
55     POST_CLEAR_KEY = 168,
56     DELETE_ALL_KEY = 169,       /* legacy */
57     DELETE_KEY = 170,
58     DELETE_RANGE_KEY = 171,
59     SYSTEM_EVENT_ONLY_KEY = 172,
60     OEM_EVENT_ONLY_KEY = 173,
61     OUTPUT_MANUFACTURER_ID_KEY = 174,
62     OUTPUT_EVENT_STATE_KEY = 175,
63     EVENT_STATE_CONFIG_FILE_KEY = 176,
64     HEX_DUMP_KEY = 177,
65     ASSUME_SYSTEM_EVENT_RECORDS_KEY = 178, /* legacy */
66     INTERPRET_OEM_DATA_KEY = 179,
67     OUTPUT_OEM_EVENT_STRINGS_KEY = 180,
68     ENTITY_SENSOR_NAMES_KEY = 181,
69     NO_SENSOR_TYPE_OUTPUT_KEY = 182,
70     COMMA_SEPARATED_OUTPUT_KEY = 183,
71     NO_HEADER_OUTPUT_KEY = 184,
72     NON_ABBREVIATED_UNITS_KEY = 185,
73     LEGACY_OUTPUT_KEY = 186,
74   };
75 
76 struct ipmi_sel_arguments
77 {
78   struct common_cmd_args common_args;
79   unsigned int verbose_count;
80   int info;
81   int display;
82   uint16_t display_record_list[IPMI_SEL_MAX_RECORD];
83   unsigned int display_record_list_length;
84   int exclude_display;
85   uint16_t exclude_display_record_list[IPMI_SEL_MAX_RECORD];
86   unsigned int exclude_display_record_list_length;
87   int display_range;
88   uint16_t display_range1;
89   uint16_t display_range2;
90   int exclude_display_range;
91   uint16_t exclude_display_range1;
92   uint16_t exclude_display_range2;
93   int date_range;
94   uint32_t date_range1;
95   uint32_t date_range2;
96   int exclude_date_range;
97   uint32_t exclude_date_range1;
98   uint32_t exclude_date_range2;
99   char sensor_types[MAX_SENSOR_TYPES][MAX_SENSOR_TYPES_STRING_LENGTH+1];
100   unsigned int sensor_types_length;
101   char exclude_sensor_types[MAX_SENSOR_TYPES][MAX_SENSOR_TYPES_STRING_LENGTH+1];
102   unsigned int exclude_sensor_types_length;
103   int list_sensor_types;
104   int tail;
105   uint16_t tail_count;
106   int clear;
107   int post_clear;
108   int delete;
109   uint16_t delete_record_list[IPMI_SEL_MAX_RECORD];
110   unsigned int delete_record_list_length;
111   int delete_range;
112   uint16_t delete_range1;
113   uint16_t delete_range2;
114   int system_event_only;
115   int oem_event_only;
116   int output_manufacturer_id;
117   int output_event_state;
118   char *event_state_config_file;
119   int hex_dump;
120   int assume_system_event_records; /* legacy */
121   int interpret_oem_data;
122   int output_oem_event_strings;
123   int entity_sensor_names;
124   int no_sensor_type_output;
125   int comma_separated_output;
126   int no_header_output;
127   int non_abbreviated_units;
128   int legacy_output;
129 };
130 
131 typedef struct ipmi_sel_prog_data
132 {
133   char *progname;
134   struct ipmi_sel_arguments *args;
135 } ipmi_sel_prog_data_t;
136 
137 typedef struct ipmi_sel_state_data
138 {
139   ipmi_sel_prog_data_t *prog_data;
140   ipmi_ctx_t ipmi_ctx;
141   pstdout_state_t pstate;
142   char *hostname;
143   ipmi_sdr_ctx_t sdr_ctx;
144   ipmi_sel_ctx_t sel_ctx;
145   ipmi_interpret_ctx_t interpret_ctx;
146   int output_headers;
147   struct sensor_column_width column_width;
148   struct ipmi_oem_data oem_data;
149   /* for tail usage */
150   uint16_t first_record_id;
151   uint16_t last_record_id;
152 } ipmi_sel_state_data_t;
153 
154 #endif /* IPMI_SEL__H */
155