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 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif /* HAVE_CONFIG_H */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <errno.h>
26
27 #include "freeipmi/cmds/ipmi-sel-cmds.h"
28 #include "freeipmi/fiid/fiid.h"
29 #include "freeipmi/spec/ipmi-cmd-spec.h"
30
31 #include "libcommon/ipmi-fiid-util.h"
32 #include "libcommon/ipmi-fill-util.h"
33 #include "libcommon/ipmi-trace.h"
34
35 #include "freeipmi-portability.h"
36
37 fiid_template_t tmpl_cmd_get_sel_info_rq =
38 {
39 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
40 { 0, "", 0}
41 };
42
43 fiid_template_t tmpl_cmd_get_sel_info_rs =
44 {
45 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
46 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
47 { 4, "sel_version_major", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
48 { 4, "sel_version_minor", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
49 { 16, "entries", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
50 { 16, "free_space", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
51 { 32, "most_recent_addition_timestamp", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
52 { 32, "most_recent_erase_timestamp", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
53 { 1, "get_sel_allocation_info_command_supported", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
54 { 1, "reserve_sel_command_supported", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
55 { 1, "partial_add_sel_entry_command_supported", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
56 { 1, "delete_sel_command_supported", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
57 { 3, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
58 { 1, "overflow_flag", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
59 { 0, "", 0}
60 };
61
62 fiid_template_t tmpl_cmd_get_sel_allocation_info_rq =
63 {
64 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
65 { 0, "", 0}
66 };
67
68 fiid_template_t tmpl_cmd_get_sel_allocation_info_rs =
69 {
70 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
71 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
72 { 16, "number_of_possible_allocation_units", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
73 { 16, "allocation_unit_size", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
74 { 16, "number_of_free_allocation_units", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
75 { 16, "largest_free_block", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
76 { 8, "maximum_record_size", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
77 { 0, "", 0}
78 };
79
80 fiid_template_t tmpl_cmd_reserve_sel_rq =
81 {
82 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
83 { 0, "", 0}
84 };
85
86 fiid_template_t tmpl_cmd_reserve_sel_rs =
87 {
88 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
89 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
90 { 16, "reservation_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
91 { 0, "", 0}
92 };
93
94 fiid_template_t tmpl_cmd_get_sel_entry_rq =
95 {
96 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
97 { 16, "reservation_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
98 { 16, "record_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
99 { 8, "offset_into_record", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
100 { 8, "bytes_to_read", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
101 { 0, "", 0}
102 };
103
104 fiid_template_t tmpl_cmd_get_sel_entry_rs =
105 {
106 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
107 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
108 { 16, "next_record_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
109 { 128, "record_data", FIID_FIELD_OPTIONAL | FIID_FIELD_LENGTH_VARIABLE},
110 { 0, "", 0}
111 };
112
113 fiid_template_t tmpl_cmd_delete_sel_entry_rq =
114 {
115 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
116 { 16, "reservation_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
117 { 16, "record_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
118 { 0, "", 0}
119 };
120
121
122 fiid_template_t tmpl_cmd_delete_sel_entry_rs =
123 {
124 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
125 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
126 { 16, "record_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
127 { 0, "", 0}
128 };
129
130 fiid_template_t tmpl_cmd_clear_sel_rq =
131 {
132 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
133 { 16, "reservation_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
134 { 8, "C", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
135 { 8, "L", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
136 { 8, "R", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
137 { 8, "operation", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
138 { 0, "", 0}
139 };
140
141 fiid_template_t tmpl_cmd_clear_sel_rs =
142 {
143 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
144 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
145 { 4, "erasure_progress", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
146 { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
147 { 0, "", 0}
148 };
149
150 fiid_template_t tmpl_cmd_get_sel_time_rq =
151 {
152 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
153 { 0, "", 0}
154 };
155
156 fiid_template_t tmpl_cmd_get_sel_time_rs =
157 {
158 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
159 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
160 { 32, "time", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
161 { 0, "", 0}
162 };
163
164 fiid_template_t tmpl_cmd_set_sel_time_rq =
165 {
166 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
167 { 32, "time", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
168 { 0, "", 0}
169 };
170
171 fiid_template_t tmpl_cmd_set_sel_time_rs =
172 {
173 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
174 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
175 { 0, "", 0}
176 };
177
178 fiid_template_t tmpl_cmd_get_sel_time_utc_offset_rq =
179 {
180 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
181 { 0, "", 0}
182 };
183
184 fiid_template_t tmpl_cmd_get_sel_time_utc_offset_rs =
185 {
186 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
187 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
188 { 16, "offset", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
189 { 0, "", 0}
190 };
191
192 fiid_template_t tmpl_cmd_set_sel_time_utc_offset_rq =
193 {
194 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
195 { 16, "offset", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
196 { 0, "", 0}
197 };
198
199 fiid_template_t tmpl_cmd_set_sel_time_utc_offset_rs =
200 {
201 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
202 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
203 { 0, "", 0}
204 };
205
206 fiid_template_t tmpl_cmd_get_auxiliary_log_status_rq =
207 {
208 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
209 { 4, "log_type", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
210 { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
211 { 0, "", 0}
212 };
213
214 fiid_template_t tmpl_cmd_get_auxiliary_log_status_rs =
215 {
216 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
217 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
218 { 120, "log_data", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_VARIABLE},
219 { 0, "", 0}
220 };
221
222 fiid_template_t tmpl_cmd_get_auxiliary_log_status_mca_rs =
223 {
224 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
225 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
226 { 32, "timestamp", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
227 { 32, "mca_log_entry_count", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED}, /* LS byte first */
228 { 56, "log_data", FIID_FIELD_OPTIONAL | FIID_FIELD_LENGTH_VARIABLE},
229 { 0, "", 0}
230 };
231
232 fiid_template_t tmpl_cmd_get_auxiliary_log_status_oem_rs =
233 {
234 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
235 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
236 { 32, "timestamp", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
237 { 24, "oem_id", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
238 { 64, "log_data", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_VARIABLE},
239 { 0, "", 0}
240 };
241
242 fiid_template_t tmpl_cmd_set_auxiliary_log_status_rq =
243 {
244 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
245 { 4, "log_type", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
246 { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
247 { 120, "log_data", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_VARIABLE},
248 { 0, "", 0}
249 };
250
251 fiid_template_t tmpl_cmd_set_auxiliary_log_status_rs =
252 {
253 { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
254 { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
255 { 0, "", 0}
256 };
257
258 int
fill_cmd_get_sel_info(fiid_obj_t obj_cmd_rq)259 fill_cmd_get_sel_info (fiid_obj_t obj_cmd_rq)
260 {
261 if (!fiid_obj_valid (obj_cmd_rq))
262 {
263 SET_ERRNO (EINVAL);
264 return (-1);
265 }
266
267 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sel_info_rq) < 0)
268 {
269 ERRNO_TRACE (errno);
270 return (-1);
271 }
272
273 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
274 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SEL_INFO);
275 return (0);
276 }
277
278 int
fill_cmd_get_sel_allocation_info(fiid_obj_t obj_cmd_rq)279 fill_cmd_get_sel_allocation_info (fiid_obj_t obj_cmd_rq)
280 {
281 if (!fiid_obj_valid (obj_cmd_rq))
282 {
283 SET_ERRNO (EINVAL);
284 return (-1);
285 }
286
287 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sel_allocation_info_rq) < 0)
288 {
289 ERRNO_TRACE (errno);
290 return (-1);
291 }
292
293 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
294 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SEL_ALLOCATION_INFO);
295 return (0);
296 }
297
298 int
fill_cmd_reserve_sel(fiid_obj_t obj_cmd_rq)299 fill_cmd_reserve_sel (fiid_obj_t obj_cmd_rq)
300 {
301 if (!fiid_obj_valid (obj_cmd_rq))
302 {
303 SET_ERRNO (EINVAL);
304 return (-1);
305 }
306
307 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_reserve_sel_rq) < 0)
308 {
309 ERRNO_TRACE (errno);
310 return (-1);
311 }
312
313 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
314 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_RESERVE_SEL);
315 return (0);
316 }
317
318 int
fill_cmd_get_sel_entry(uint16_t reservation_id,uint16_t record_id,uint8_t offset_into_record,uint8_t bytes_to_read,fiid_obj_t obj_cmd_rq)319 fill_cmd_get_sel_entry (uint16_t reservation_id,
320 uint16_t record_id,
321 uint8_t offset_into_record,
322 uint8_t bytes_to_read,
323 fiid_obj_t obj_cmd_rq)
324 {
325 if (!fiid_obj_valid (obj_cmd_rq))
326 {
327 SET_ERRNO (EINVAL);
328 return (-1);
329 }
330
331 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sel_entry_rq) < 0)
332 {
333 ERRNO_TRACE (errno);
334 return (-1);
335 }
336
337 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
338 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SEL_ENTRY);
339 FILL_FIID_OBJ_SET (obj_cmd_rq, "reservation_id", reservation_id);
340 FILL_FIID_OBJ_SET (obj_cmd_rq, "record_id", record_id);
341 FILL_FIID_OBJ_SET (obj_cmd_rq, "offset_into_record", offset_into_record);
342 FILL_FIID_OBJ_SET (obj_cmd_rq, "bytes_to_read", bytes_to_read);
343
344 return (0);
345 }
346
347 int
fill_cmd_delete_sel_entry(uint16_t reservation_id,uint16_t record_id,fiid_obj_t obj_cmd_rq)348 fill_cmd_delete_sel_entry (uint16_t reservation_id,
349 uint16_t record_id,
350 fiid_obj_t obj_cmd_rq)
351 {
352 if (!fiid_obj_valid (obj_cmd_rq))
353 {
354 SET_ERRNO (EINVAL);
355 return (-1);
356 }
357
358 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_delete_sel_entry_rq) < 0)
359 {
360 ERRNO_TRACE (errno);
361 return (-1);
362 }
363
364 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
365 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_DELETE_SEL_ENTRY);
366 FILL_FIID_OBJ_SET (obj_cmd_rq, "reservation_id", reservation_id);
367 FILL_FIID_OBJ_SET (obj_cmd_rq, "record_id", record_id);
368
369 return (0);
370 }
371
372 int
fill_cmd_clear_sel(uint16_t reservation_id,uint8_t operation,fiid_obj_t obj_cmd_rq)373 fill_cmd_clear_sel (uint16_t reservation_id,
374 uint8_t operation,
375 fiid_obj_t obj_cmd_rq)
376 {
377 if (!IPMI_SEL_CLEAR_OPERATION_VALID (operation)
378 || !fiid_obj_valid (obj_cmd_rq))
379 {
380 SET_ERRNO (EINVAL);
381 return (-1);
382 }
383
384 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_clear_sel_rq) < 0)
385 {
386 ERRNO_TRACE (errno);
387 return (-1);
388 }
389
390 /* achu: the "CLR" is exactly from the spec. I know it looks dumb */
391 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
392 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_CLEAR_SEL);
393 FILL_FIID_OBJ_SET (obj_cmd_rq, "reservation_id", reservation_id);
394 FILL_FIID_OBJ_SET (obj_cmd_rq, "C", 'C');
395 FILL_FIID_OBJ_SET (obj_cmd_rq, "L", 'L');
396 FILL_FIID_OBJ_SET (obj_cmd_rq, "R", 'R');
397 FILL_FIID_OBJ_SET (obj_cmd_rq, "operation", operation);
398
399 return (0);
400 }
401
402 int
fill_cmd_get_sel_time(fiid_obj_t obj_cmd_rq)403 fill_cmd_get_sel_time (fiid_obj_t obj_cmd_rq)
404 {
405 if (!fiid_obj_valid (obj_cmd_rq))
406 {
407 SET_ERRNO (EINVAL);
408 return (-1);
409 }
410
411 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sel_time_rq) < 0)
412 {
413 ERRNO_TRACE (errno);
414 return (-1);
415 }
416
417 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
418 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SEL_TIME);
419
420 return (0);
421 }
422
423 int
fill_cmd_set_sel_time(uint32_t time,fiid_obj_t obj_cmd_rq)424 fill_cmd_set_sel_time (uint32_t time, fiid_obj_t obj_cmd_rq)
425 {
426 if (!fiid_obj_valid (obj_cmd_rq))
427 {
428 SET_ERRNO (EINVAL);
429 return (-1);
430 }
431
432 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sel_time_rq) < 0)
433 {
434 ERRNO_TRACE (errno);
435 return (-1);
436 }
437
438 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
439 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SEL_TIME);
440 FILL_FIID_OBJ_SET (obj_cmd_rq, "time", time);
441
442 return (0);
443 }
444
445 int
fill_cmd_get_sel_time_utc_offset(fiid_obj_t obj_cmd_rq)446 fill_cmd_get_sel_time_utc_offset (fiid_obj_t obj_cmd_rq)
447 {
448 if (!fiid_obj_valid (obj_cmd_rq))
449 {
450 SET_ERRNO (EINVAL);
451 return (-1);
452 }
453
454 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sel_time_utc_offset_rq) < 0)
455 {
456 ERRNO_TRACE (errno);
457 return (-1);
458 }
459
460 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
461 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SEL_TIME_UTC_OFFSET);
462
463 return (0);
464 }
465
466 int
fill_cmd_set_sel_time_utc_offset(int16_t offset,fiid_obj_t obj_cmd_rq)467 fill_cmd_set_sel_time_utc_offset (int16_t offset, fiid_obj_t obj_cmd_rq)
468 {
469 if (!IPMI_SEL_TIME_UTC_OFFSET_VALID (offset)
470 || !fiid_obj_valid (obj_cmd_rq))
471 {
472 SET_ERRNO (EINVAL);
473 return (-1);
474 }
475
476 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sel_time_utc_offset_rq) < 0)
477 {
478 ERRNO_TRACE (errno);
479 return (-1);
480 }
481
482 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
483 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SEL_TIME_UTC_OFFSET);
484 FILL_FIID_OBJ_SET (obj_cmd_rq, "offset", (uint64_t)offset);
485
486 return (0);
487 }
488
489 int
fill_cmd_get_auxiliary_log_status(uint8_t log_type,fiid_obj_t obj_cmd_rq)490 fill_cmd_get_auxiliary_log_status (uint8_t log_type,
491 fiid_obj_t obj_cmd_rq)
492 {
493 if (!IPMI_AUXILIARY_LOG_TYPE_VALID (log_type)
494 || !fiid_obj_valid (obj_cmd_rq))
495 {
496 SET_ERRNO (EINVAL);
497 return (-1);
498 }
499
500 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_auxiliary_log_status_rq) < 0)
501 {
502 ERRNO_TRACE (errno);
503 return (-1);
504 }
505
506 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
507 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_AUXILIARY_LOG_STATUS);
508 FILL_FIID_OBJ_SET (obj_cmd_rq, "log_type", log_type);
509 FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved", 0);
510
511 return (0);
512 }
513
514 int
fill_cmd_set_auxiliary_log_status(uint8_t log_type,const void * log_data,unsigned int log_data_len,fiid_obj_t obj_cmd_rq)515 fill_cmd_set_auxiliary_log_status (uint8_t log_type,
516 const void *log_data,
517 unsigned int log_data_len,
518 fiid_obj_t obj_cmd_rq)
519 {
520 if (!IPMI_AUXILIARY_LOG_TYPE_VALID (log_type)
521 || !log_data
522 || !log_data_len
523 || !fiid_obj_valid (obj_cmd_rq))
524 {
525 SET_ERRNO (EINVAL);
526 return (-1);
527 }
528
529 if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_auxiliary_log_status_rq) < 0)
530 {
531 ERRNO_TRACE (errno);
532 return (-1);
533 }
534
535 FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
536 FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_AUXILIARY_LOG_STATUS);
537 FILL_FIID_OBJ_SET (obj_cmd_rq, "log_type", log_type);
538 FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved", 0);
539
540 FILL_FIID_OBJ_SET_DATA (obj_cmd_rq,
541 "log_data",
542 log_data,
543 log_data_len);
544
545 return (0);
546 }
547