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-sol-cmds.h"
28 #include "freeipmi/fiid/fiid.h"
29 #include "freeipmi/spec/ipmi-channel-spec.h"
30 #include "freeipmi/spec/ipmi-cmd-spec.h"
31 #include "freeipmi/spec/ipmi-privilege-level-spec.h"
32 #include "freeipmi/spec/ipmi-sol-configuration-parameters-spec.h"
33 
34 #include "libcommon/ipmi-fiid-util.h"
35 #include "libcommon/ipmi-fill-util.h"
36 #include "libcommon/ipmi-trace.h"
37 
38 #include "freeipmi-portability.h"
39 
40 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_rq =
41   {
42     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
43     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
44     { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
45     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
46     { 1024, "configuration_parameter_data", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_VARIABLE},
47     { 0, "", 0}
48   };
49 
50 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_rs =
51   {
52     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
53     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
54     { 0, "", 0}
55   };
56 
57 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_set_in_progress_rq =
58   {
59     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
60     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
61     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
62     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
63     { 2, "state", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
64     { 6, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
65     { 0, "", 0}
66   };
67 
68 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_enable_rq =
69   {
70     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
71     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
72     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
73     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
74     { 1, "sol_enable", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
75     { 7, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
76     { 0, "", 0}
77   };
78 
79 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_authentication_rq =
80   {
81     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
82     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
83     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
84     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
85     { 4, "sol_privilege_level", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
86     { 2, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
87     { 1, "force_sol_payload_authentication", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
88     { 1, "force_sol_payload_encryption", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
89     { 0, "", 0}
90   };
91 
92 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_character_accumulate_interval_and_send_threshold_rq =
93   {
94     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
95     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
96     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
97     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
98     { 8, "character_accumulate_interval", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
99     { 8, "character_send_threshold", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
100     { 0, "", 0}
101   };
102 
103 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_retry_rq =
104   {
105     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
106     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
107     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
108     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
109     { 3, "retry_count", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
110     { 5, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
111     { 8, "retry_interval", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
112     { 0, "", 0}
113   };
114 
115 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_non_volatile_bit_rate_rq =
116   {
117     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
118     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
119     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
120     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
121     { 4, "bit_rate", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
122     { 4, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
123     { 0, "", 0}
124   };
125 
126 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_volatile_bit_rate_rq =
127   {
128     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
129     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
130     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
131     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
132     { 4, "bit_rate", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
133     { 4, "reserved2", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
134     { 0, "", 0}
135   };
136 
137 fiid_template_t tmpl_cmd_set_sol_configuration_parameters_sol_payload_port_number_rq =
138   {
139     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
140     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
141     { 4, "reserved1", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
142     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
143     { 16, "port_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
144     { 0, "", 0}
145   };
146 
147 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_rq =
148   {
149     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
150     { 4, "channel_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
151     { 3, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
152     { 1, "get_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
153     { 8, "parameter_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
154     { 8, "set_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
155     { 8, "block_selector", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
156     { 0, "", 0}
157   };
158 
159 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_rs =
160   {
161     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
162     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
163     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
164     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
165     { 1024, "configuration_parameter_data", FIID_FIELD_OPTIONAL | FIID_FIELD_LENGTH_VARIABLE},
166     { 0, "", 0}
167   };
168 
169 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_set_in_progress_rs =
170   {
171     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
172     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
173     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
174     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
175     { 2, "state", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
176     { 6, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
177     { 0, "", 0}
178   };
179 
180 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_enable_rs =
181   {
182     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
183     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
184     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
185     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
186     { 1, "sol_enable", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
187     { 7, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
188     { 0, "", 0}
189   };
190 
191 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_authentication_rs =
192   {
193     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
194     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
195     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
196     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
197     { 4, "sol_privilege_level", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
198     { 2, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
199     { 1, "force_sol_payload_authentication", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
200     { 1, "force_sol_payload_encryption", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
201     { 0, "", 0}
202   };
203 
204 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_character_accumulate_interval_and_send_threshold_rs =
205   {
206     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
207     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
208     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
209     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
210     { 8, "character_accumulate_interval", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
211     { 8, "character_send_threshold", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
212     { 0, "", 0}
213   };
214 
215 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_retry_rs =
216   {
217     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
218     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
219     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
220     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
221     { 3, "retry_count", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
222     { 5, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
223     { 8, "retry_interval", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
224     { 0, "", 0}
225   };
226 
227 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_non_volatile_bit_rate_rs =
228   {
229     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
230     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
231     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
232     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
233     { 4, "bit_rate", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
234     { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
235     { 0, "", 0}
236   };
237 
238 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_volatile_bit_rate_rs =
239   {
240     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
241     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
242     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
243     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
244     { 4, "bit_rate", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
245     { 4, "reserved", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
246     { 0, "", 0}
247   };
248 
249 /* Note: Read-Only field, no 'set' equivalent */
250 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_payload_channel_rs =
251   {
252     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
253     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
254     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
255     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
256     { 8, "payload_channel", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
257     { 0, "", 0}
258   };
259 
260 fiid_template_t tmpl_cmd_get_sol_configuration_parameters_sol_payload_port_number_rs =
261   {
262     { 8, "cmd", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
263     { 8, "comp_code", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED | FIID_FIELD_MAKES_PACKET_SUFFICIENT},
264     { 4, "present_revision", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
265     { 4, "oldest_revision_parameter", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
266     { 16, "port_number", FIID_FIELD_REQUIRED | FIID_FIELD_LENGTH_FIXED},
267     { 0, "", 0}
268   };
269 
270 int
fill_cmd_set_sol_configuration_parameters(uint8_t channel_number,uint8_t parameter_selector,const void * configuration_parameter_data,unsigned int configuration_parameter_data_len,fiid_obj_t obj_cmd_rq)271 fill_cmd_set_sol_configuration_parameters (uint8_t channel_number,
272                                            uint8_t parameter_selector,
273                                            const void *configuration_parameter_data,
274                                            unsigned int configuration_parameter_data_len,
275                                            fiid_obj_t obj_cmd_rq)
276 {
277   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
278       || (!IPMI_SOL_CONFIGURATION_PARAMETER_SELECTOR_VALID (parameter_selector)
279           && !IPMI_SOL_CONFIGURATION_PARAMETER_SELECTOR_IS_OEM (parameter_selector))
280       || !configuration_parameter_data
281       || !configuration_parameter_data_len
282       || !fiid_obj_valid (obj_cmd_rq))
283     {
284       SET_ERRNO (EINVAL);
285       return (-1);
286     }
287 
288   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_rq) < 0)
289     {
290       ERRNO_TRACE (errno);
291       return (-1);
292     }
293 
294   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
295   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
296   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
297   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved", 0);
298   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", parameter_selector);
299   FILL_FIID_OBJ_SET_DATA (obj_cmd_rq,
300                           "configuration_parameter_data",
301                           configuration_parameter_data,
302                           configuration_parameter_data_len);
303 
304   return (0);
305 }
306 
307 int
fill_cmd_set_sol_configuration_parameters_set_in_progress(uint8_t channel_number,uint8_t state,fiid_obj_t obj_cmd_rq)308 fill_cmd_set_sol_configuration_parameters_set_in_progress (uint8_t channel_number,
309                                                            uint8_t state,
310                                                            fiid_obj_t obj_cmd_rq)
311 {
312   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
313       || !IPMI_SOL_CONFIGURATION_PARAMETERS_SET_IN_PROGRESS_VALID (state)
314       || !fiid_obj_valid (obj_cmd_rq))
315     {
316       SET_ERRNO (EINVAL);
317       return (-1);
318     }
319 
320   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_set_in_progress_rq) < 0)
321     {
322       ERRNO_TRACE (errno);
323       return (-1);
324     }
325 
326   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
327   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
328   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
329   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
330   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SET_IN_PROGRESS);
331   FILL_FIID_OBJ_SET (obj_cmd_rq, "state", state);
332   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
333   return (0);
334 }
335 
336 int
fill_cmd_set_sol_configuration_parameters_sol_enable(uint8_t channel_number,uint8_t sol_enable,fiid_obj_t obj_cmd_rq)337 fill_cmd_set_sol_configuration_parameters_sol_enable (uint8_t channel_number,
338                                                       uint8_t sol_enable,
339                                                       fiid_obj_t obj_cmd_rq)
340 {
341   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
342       || !IPMI_SOL_SOL_ENABLE_VALID (sol_enable)
343       || !fiid_obj_valid (obj_cmd_rq))
344     {
345       SET_ERRNO (EINVAL);
346       return (-1);
347     }
348 
349   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_sol_enable_rq) < 0)
350     {
351       ERRNO_TRACE (errno);
352       return (-1);
353     }
354 
355   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
356   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
357   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
358   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
359   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_ENABLE);
360   FILL_FIID_OBJ_SET (obj_cmd_rq, "sol_enable", sol_enable);
361   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
362 
363   return (0);
364 }
365 
366 int
fill_cmd_set_sol_configuration_parameters_sol_authentication(uint8_t channel_number,uint8_t sol_privilege_level,uint8_t force_sol_payload_authentication,uint8_t force_sol_payload_encryption,fiid_obj_t obj_cmd_rq)367 fill_cmd_set_sol_configuration_parameters_sol_authentication (uint8_t channel_number,
368                                                               uint8_t sol_privilege_level,
369                                                               uint8_t force_sol_payload_authentication,
370                                                               uint8_t force_sol_payload_encryption,
371                                                               fiid_obj_t obj_cmd_rq)
372 {
373   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
374       || !IPMI_PRIVILEGE_LEVEL_VALID (sol_privilege_level)
375       || !IPMI_SOL_FORCE_SOL_PAYLOAD_AUTHENTICATION_VALID (force_sol_payload_authentication)
376       || !IPMI_SOL_FORCE_SOL_PAYLOAD_ENCRYPTION_VALID (force_sol_payload_encryption)
377       || !fiid_obj_valid (obj_cmd_rq))
378     {
379       SET_ERRNO (EINVAL);
380       return (-1);
381     }
382 
383   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_sol_authentication_rq) < 0)
384     {
385       ERRNO_TRACE (errno);
386       return (-1);
387     }
388 
389   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
390   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
391   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
392   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
393   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_AUTHENTICATION);
394   FILL_FIID_OBJ_SET (obj_cmd_rq, "sol_privilege_level", sol_privilege_level);
395   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
396   FILL_FIID_OBJ_SET (obj_cmd_rq, "force_sol_payload_authentication", force_sol_payload_authentication);
397   FILL_FIID_OBJ_SET (obj_cmd_rq, "force_sol_payload_encryption", force_sol_payload_encryption);
398 
399   return (0);
400 }
401 
402 int
fill_cmd_set_sol_configuration_parameters_character_accumulate_interval_and_send_threshold(uint8_t channel_number,uint8_t character_accumulate_interval,uint8_t character_send_threshold,fiid_obj_t obj_cmd_rq)403 fill_cmd_set_sol_configuration_parameters_character_accumulate_interval_and_send_threshold (uint8_t channel_number,
404                                                                                             uint8_t character_accumulate_interval,
405                                                                                             uint8_t character_send_threshold,
406                                                                                             fiid_obj_t obj_cmd_rq)
407 {
408   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
409       || !fiid_obj_valid (obj_cmd_rq))
410     {
411       SET_ERRNO (EINVAL);
412       return (-1);
413     }
414 
415   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_character_accumulate_interval_and_send_threshold_rq) < 0)
416     {
417       ERRNO_TRACE (errno);
418       return (-1);
419     }
420 
421   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
422   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
423   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
424   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
425   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_CHARACTER_ACCUMULATE_INTERVAL_AND_SEND_THRESHOLD);
426   FILL_FIID_OBJ_SET (obj_cmd_rq, "character_accumulate_interval", character_accumulate_interval);
427   FILL_FIID_OBJ_SET (obj_cmd_rq, "character_send_threshold", character_send_threshold);
428 
429   return (0);
430 }
431 
432 int
fill_cmd_set_sol_configuration_parameters_sol_retry(uint8_t channel_number,uint8_t retry_count,uint8_t retry_interval,fiid_obj_t obj_cmd_rq)433 fill_cmd_set_sol_configuration_parameters_sol_retry (uint8_t channel_number,
434                                                      uint8_t retry_count,
435                                                      uint8_t retry_interval,
436                                                      fiid_obj_t obj_cmd_rq)
437 {
438   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
439       || !fiid_obj_valid (obj_cmd_rq))
440     {
441       SET_ERRNO (EINVAL);
442       return (-1);
443     }
444 
445   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_sol_retry_rq) < 0)
446     {
447       ERRNO_TRACE (errno);
448       return (-1);
449     }
450 
451   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
452   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
453   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
454   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
455   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_RETRY);
456   FILL_FIID_OBJ_SET (obj_cmd_rq, "retry_count", retry_count);
457   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
458   FILL_FIID_OBJ_SET (obj_cmd_rq, "retry_interval", retry_interval);
459 
460   return (0);
461 }
462 
463 int
fill_cmd_set_sol_configuration_parameters_sol_non_volatile_bit_rate(uint8_t channel_number,uint8_t bit_rate,fiid_obj_t obj_cmd_rq)464 fill_cmd_set_sol_configuration_parameters_sol_non_volatile_bit_rate (uint8_t channel_number,
465                                                                      uint8_t bit_rate,
466                                                                      fiid_obj_t obj_cmd_rq)
467 {
468   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
469       || !IPMI_SOL_BIT_RATE_VALID (bit_rate)
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_sol_configuration_parameters_sol_non_volatile_bit_rate_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_SOL_CONFIGURATION_PARAMETERS);
484   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
485   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
486   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_NON_VOLATILE_BIT_RATE);
487   FILL_FIID_OBJ_SET (obj_cmd_rq, "bit_rate", bit_rate);
488   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
489 
490   return (0);
491 }
492 
493 int
fill_cmd_set_sol_configuration_parameters_sol_volatile_bit_rate(uint8_t channel_number,uint8_t bit_rate,fiid_obj_t obj_cmd_rq)494 fill_cmd_set_sol_configuration_parameters_sol_volatile_bit_rate (uint8_t channel_number,
495                                                                  uint8_t bit_rate,
496                                                                  fiid_obj_t obj_cmd_rq)
497 {
498   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
499       || !IPMI_SOL_BIT_RATE_VALID (bit_rate)
500       || !fiid_obj_valid (obj_cmd_rq))
501     {
502       SET_ERRNO (EINVAL);
503       return (-1);
504     }
505 
506   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_sol_volatile_bit_rate_rq) < 0)
507     {
508       ERRNO_TRACE (errno);
509       return (-1);
510     }
511 
512   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
513   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
514   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
515   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
516   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_VOLATILE_BIT_RATE);
517   FILL_FIID_OBJ_SET (obj_cmd_rq, "bit_rate", bit_rate);
518   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved2", 0);
519 
520   return (0);
521 }
522 
523 int
fill_cmd_set_sol_configuration_parameters_sol_payload_port_number(uint8_t channel_number,uint16_t port_number,fiid_obj_t obj_cmd_rq)524 fill_cmd_set_sol_configuration_parameters_sol_payload_port_number (uint8_t channel_number,
525                                                                    uint16_t port_number,
526                                                                    fiid_obj_t obj_cmd_rq)
527 {
528   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
529       || !fiid_obj_valid (obj_cmd_rq))
530     {
531       SET_ERRNO (EINVAL);
532       return (-1);
533     }
534 
535   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_set_sol_configuration_parameters_sol_payload_port_number_rq) < 0)
536     {
537       ERRNO_TRACE (errno);
538       return (-1);
539     }
540 
541   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
542   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS);
543   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
544   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved1", 0);
545   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", IPMI_SOL_CONFIGURATION_PARAMETER_SOL_PAYLOAD_PORT_NUMBER);
546   FILL_FIID_OBJ_SET (obj_cmd_rq, "port_number", port_number);
547 
548   return (0);
549 }
550 
551 int
fill_cmd_get_sol_configuration_parameters(uint8_t channel_number,uint8_t get_parameter,uint8_t parameter_selector,uint8_t set_selector,uint8_t block_selector,fiid_obj_t obj_cmd_rq)552 fill_cmd_get_sol_configuration_parameters (uint8_t channel_number,
553                                            uint8_t get_parameter,
554                                            uint8_t parameter_selector,
555                                            uint8_t set_selector,
556                                            uint8_t block_selector,
557                                            fiid_obj_t obj_cmd_rq)
558 {
559   if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)
560       || !IPMI_GET_SOL_PARAMETER_VALID (get_parameter)
561       || (!IPMI_SOL_CONFIGURATION_PARAMETER_SELECTOR_VALID (parameter_selector)
562           && !IPMI_SOL_CONFIGURATION_PARAMETER_SELECTOR_IS_OEM (parameter_selector))
563       || !fiid_obj_valid (obj_cmd_rq))
564     {
565       SET_ERRNO (EINVAL);
566       return (-1);
567     }
568 
569   if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_get_sol_configuration_parameters_rq) < 0)
570     {
571       ERRNO_TRACE (errno);
572       return (-1);
573     }
574 
575   FILL_FIID_OBJ_CLEAR (obj_cmd_rq);
576   FILL_FIID_OBJ_SET (obj_cmd_rq, "cmd", IPMI_CMD_GET_SOL_CONFIGURATION_PARAMETERS);
577   FILL_FIID_OBJ_SET (obj_cmd_rq, "channel_number", channel_number);
578   FILL_FIID_OBJ_SET (obj_cmd_rq, "reserved", 0);
579   FILL_FIID_OBJ_SET (obj_cmd_rq, "get_parameter", get_parameter);
580   FILL_FIID_OBJ_SET (obj_cmd_rq, "parameter_selector", parameter_selector);
581   FILL_FIID_OBJ_SET (obj_cmd_rq, "set_selector", set_selector);
582   FILL_FIID_OBJ_SET (obj_cmd_rq, "block_selector", block_selector);
583 
584   return (0);
585 }
586 
587