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 /* 2's complement checksum of preceding bytes in the connection header
20    or between the previous checksum. 8-bit checksum algorithm:
21    Initialize checksum to 0.
22    For each byte, checksum = (checksum + byte) modulo 256. Then find
23    1's compliment of checksum and add one to it.
24    To verify add all the bytes and the checksum and then % 256 should
25    yield 0.
26 */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif /* HAVE_CONFIG_H */
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 #ifdef STDC_HEADERS
35 #include <string.h>
36 #endif /* STDC_HEADERS */
37 #include <errno.h>
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #if HAVE_FCNTL_H
41 #include <fcntl.h>
42 #endif /* HAVE_FCNTL_H */
43 #if HAVE_UNISTD_H
44 #include <unistd.h>
45 #endif /* HAVE_UNISTD_H */
46 #if HAVE_GCRYPT_H
47 #include <gcrypt.h>
48 #endif /* HAVE_GCRYPT_H */
49 
50 #include "freeipmi/util/ipmi-util.h"
51 #include "freeipmi/fiid/fiid.h"
52 #include "freeipmi/interface/rmcp-interface.h"
53 #include "freeipmi/spec/ipmi-authentication-type-spec.h"
54 #include "freeipmi/spec/ipmi-cmd-spec.h"
55 #include "freeipmi/spec/ipmi-comp-code-spec.h"
56 #include "freeipmi/spec/ipmi-netfn-spec.h"
57 
58 #include "libcommon/ipmi-fiid-util.h"
59 #include "libcommon/ipmi-trace.h"
60 
61 #include "freeipmi-portability.h"
62 
63 #define IPMI_SEQUENCE_NUMBER_MAX            0xFFFFFFFF
64 #define IPMI_SEQUENCE_NUMBER_WINDOW_DEFAULT          8
65 #define IPMI_SEQUENCE_NUMBER_WINDOW_MAX             32
66 #define IPMI_SEQUENCE_NUMBER_WINDOW_MIN              1
67 
68 static uint8_t
_checksum(const void * buf,unsigned int buflen,uint8_t checksum_initial)69 _checksum (const void *buf, unsigned int buflen, uint8_t checksum_initial)
70 {
71   register unsigned int i = 0;
72   register int8_t checksum = checksum_initial;
73 
74   if (buf == NULL || buflen == 0)
75     return (checksum);
76 
77   for (; i < buflen; i++)
78     checksum = (checksum + ((uint8_t *)buf)[i]) % 256;
79 
80   return (checksum);
81 }
82 
83 uint8_t
ipmi_checksum(const void * buf,unsigned int buflen)84 ipmi_checksum (const void *buf, unsigned int buflen)
85 {
86   uint8_t checksum;
87   checksum = _checksum (buf, buflen, 0);
88   return (-checksum);
89 }
90 
91 uint8_t
ipmi_checksum_incremental(const void * buf,unsigned int buflen,uint8_t checksum_initial)92 ipmi_checksum_incremental (const void *buf, unsigned int buflen, uint8_t checksum_initial)
93 {
94   return (_checksum (buf, buflen, checksum_initial));
95 }
96 
97 uint8_t
ipmi_checksum_final(const void * buf,unsigned int buflen,uint8_t checksum_initial)98 ipmi_checksum_final (const void *buf, unsigned int buflen, uint8_t checksum_initial)
99 {
100   uint8_t checksum;
101 
102   if (!buf || !buflen)
103     return (-checksum_initial);
104 
105   checksum = _checksum (buf, buflen, checksum_initial);
106   return (-checksum);
107 }
108 
109 int
ipmi_check_cmd(fiid_obj_t obj_cmd,uint8_t cmd)110 ipmi_check_cmd (fiid_obj_t obj_cmd, uint8_t cmd)
111 {
112   uint8_t cmd_recv;
113   uint64_t val;
114 
115   if (!fiid_obj_valid (obj_cmd))
116     {
117       SET_ERRNO (EINVAL);
118       return (-1);
119     }
120 
121   if (FIID_OBJ_FIELD_LOOKUP (obj_cmd, "cmd") < 0)
122     {
123       FIID_OBJECT_ERROR_TO_ERRNO (obj_cmd);
124       return (-1);
125     }
126 
127   if (FIID_OBJ_GET (obj_cmd, "cmd", &val) < 0)
128     {
129       FIID_OBJECT_ERROR_TO_ERRNO (obj_cmd);
130       return (-1);
131     }
132   cmd_recv = val;
133 
134   return ((cmd_recv == cmd) ? 1 : 0);
135 }
136 
137 int
ipmi_check_completion_code(fiid_obj_t obj_cmd,uint8_t completion_code)138 ipmi_check_completion_code (fiid_obj_t obj_cmd, uint8_t completion_code)
139 {
140   uint8_t completion_code_recv;
141   uint64_t val;
142 
143   if (!fiid_obj_valid (obj_cmd))
144     {
145       SET_ERRNO (EINVAL);
146       return (-1);
147     }
148 
149   if (FIID_OBJ_FIELD_LOOKUP (obj_cmd, "comp_code") < 0)
150     {
151       FIID_OBJECT_ERROR_TO_ERRNO (obj_cmd);
152       return (-1);
153     }
154 
155   if (FIID_OBJ_GET (obj_cmd, "comp_code", &val) < 0)
156     {
157       FIID_OBJECT_ERROR_TO_ERRNO (obj_cmd);
158       return (-1);
159     }
160   completion_code_recv = val;
161 
162   return ((completion_code_recv == completion_code) ? 1 : 0);
163 }
164 
165 int
ipmi_check_completion_code_success(fiid_obj_t obj_cmd)166 ipmi_check_completion_code_success (fiid_obj_t obj_cmd)
167 {
168   return (ipmi_check_completion_code (obj_cmd, IPMI_COMP_CODE_COMMAND_SUCCESS));
169 }
170 
171 int
ipmi_get_random(void * buf,unsigned int buflen)172 ipmi_get_random (void *buf, unsigned int buflen)
173 {
174 #if (HAVE_DEVURANDOM || HAVE_DEVRANDOM)
175   int fd, len, rv = -1;
176 #endif /* !(HAVE_DEVURANDOM || HAVE_DEVRANDOM) */
177 
178   if (!buf)
179     {
180       SET_ERRNO (EINVAL);
181       return (-1);
182     }
183 
184   if (!buflen)
185     return (0);
186 
187 #if (HAVE_DEVURANDOM || HAVE_DEVRANDOM)
188 #if HAVE_DEVURANDOM
189   if ((fd = open ("/dev/urandom", O_RDONLY)) < 0)
190     goto cleanup;
191 #else  /* !HAVE_DEVURANDOM */
192   if ((fd = open ("/dev/random", O_RDONLY)) < 0)
193     goto cleanup;
194 #endif /* !HAVE_DEVURANDOM */
195 
196   if ((len = read (fd, buf, buflen)) < 0)
197     goto cleanup;
198 
199   if (((unsigned int)len) < buflen)
200     goto cleanup;
201 
202   rv = len;
203  cleanup:
204   /* ignore potential error, cleanup path */
205   close (fd);
206   return (rv);
207 #else /* !(HAVE_DEVURANDOM || HAVE_DEVRANDOM) */
208   SET_ERRNO (EPERM);
209   return (-1);
210 #endif /* !(HAVE_DEVURANDOM || HAVE_DEVRANDOM) */
211 }
212 
213 const char *
ipmi_cmd_str(uint8_t net_fn,uint8_t cmd)214 ipmi_cmd_str (uint8_t net_fn, uint8_t cmd)
215 {
216   switch (net_fn)
217     {
218     case IPMI_NET_FN_CHASSIS_RQ:
219     case IPMI_NET_FN_CHASSIS_RS:
220       switch (cmd)
221         {
222         case IPMI_CMD_GET_CHASSIS_CAPABILITIES:
223           return "Get Chassis Capabilities";
224         case IPMI_CMD_GET_CHASSIS_STATUS:
225           return "Get Chassis Status";
226         case IPMI_CMD_CHASSIS_CONTROL:
227           return "Chassis Control";
228         case IPMI_CMD_CHASSIS_RESET:
229           return "Chassis Reset";
230         case IPMI_CMD_CHASSIS_IDENTIFY:
231           return "Chassis Identify";
232         case IPMI_CMD_SET_CHASSIS_CAPABILITIES:
233           return "Set Chassis Capabilities";
234         case IPMI_CMD_SET_POWER_RESTORE_POLICY:
235           return "Set Power Restore Policy";
236         case IPMI_CMD_GET_SYSTEM_RESTART_CAUSE:
237           return "Get System Restart Cause";
238         case IPMI_CMD_SET_SYSTEM_BOOT_OPTIONS:
239           return "Set System Boot Options";
240         case IPMI_CMD_GET_SYSTEM_BOOT_OPTIONS:
241           return "Get System Boot Options";
242         case IPMI_CMD_SET_FRONT_PANEL_BUTTON_ENABLES:
243           return "Set Front Panel Button Enables";
244         case IPMI_CMD_SET_POWER_CYCLE_INTERVAL:
245           return "Set Power Cycle Interval";
246         case IPMI_CMD_GET_POWER_ON_HOURS_COUNTER:
247           return "Get Power On Hours Counter";
248         default:
249           return "Unknown";
250         }
251       break;
252     case IPMI_NET_FN_BRIDGE_RQ:
253     case IPMI_NET_FN_BRIDGE_RS:
254       switch (cmd)
255         {
256         case IPMI_CMD_GET_BRIDGE_STATE:
257           return "Get Bridge State";
258         case IPMI_CMD_SET_BRIDGE_STATE:
259           return "Set Bridge State";
260         case IPMI_CMD_GET_ICMB_ADDRESS:
261           return "Get ICM Address";
262         case IPMI_CMD_SET_ICMB_ADDRESS:
263           return "Set ICMB Address";
264         case IPMI_CMD_SET_BRIDGE_PROXY_ADDRESS:
265           return "Set Bridge Proxy Address";
266         case IPMI_CMD_GET_BRIDGE_STATISTICS:
267           return "Get Bridge Statistics";
268         case IPMI_CMD_GET_ICMB_CAPABILITIES:
269           return "Get ICMB Capabilities";
270         case IPMI_CMD_CLEAR_BRIDGE_STATISTICS:
271           return "Clear Bridge Statistics";
272         case IPMI_CMD_GET_BRIDGE_PROXY_ADDRESS:
273           return "Get Bridge Proxy Address";
274         case IPMI_CMD_GET_ICMB_CONNECTOR_INFO:
275           return "Get ICMB Connector Info";
276         case IPMI_CMD_GET_ICMB_CONNECTION_ID:
277           return "Get ICMB Connection ID";
278         case IPMI_CMD_SEND_ICMB_CONNECTION_ID:
279           return "Send ICMB Connection ID";
280         case IPMI_CMD_PREPARE_FOR_DISCOVERY:
281           return "Prepare For Discovery";
282         case IPMI_CMD_GET_ADDRESSES:
283           return "Get Addresses";
284         case IPMI_CMD_SET_DISCOVERED:
285           return "Set Discovered";
286         case IPMI_CMD_GET_CHASSIS_DEVICE_ID:
287           return "Get Chassis Device ID";
288         case IPMI_CMD_SET_CHASSIS_DEVICE_ID:
289           return "Set Chassis Device ID";
290         case IPMI_CMD_BRIDGE_REQUEST:
291           return "Bridge Request";
292         case IPMI_CMD_BRIDGE_MESSAGE:
293           return "Bridge Message";
294         case IPMI_CMD_GET_EVENT_COUNT:
295           return "Get Event Count";
296         case IPMI_CMD_SET_EVENT_DESTINATION:
297           return "Set Event Destination";
298         case IPMI_CMD_SET_EVENT_RECEPTION_STATE:
299           return "Set Event Reception State";
300         case IPMI_CMD_SEND_ICMB_EVENT_MESSAGE:
301           return "Send ICMB Event Message";
302         case IPMI_CMD_GET_EVENT_DESTINATION:
303           return "Get Event Destination";
304         case IPMI_CMD_GET_EVENT_RECEPTION_STATE:
305           return "Get Event Reception State";
306         case IPMI_CMD_ERROR_REPORT:
307           return "Error Report";
308         default:
309           return "Unknown";
310         }
311       break;
312     case IPMI_NET_FN_SENSOR_EVENT_RQ:
313     case IPMI_NET_FN_SENSOR_EVENT_RS:
314       switch (cmd)
315         {
316         case IPMI_CMD_SET_EVENT_RECEIVER:
317           return "Set Event Receiver";
318         case IPMI_CMD_GET_EVENT_RECEIVER:
319           return "Get Event Receiver";
320         case IPMI_CMD_PLATFORM_EVENT:
321           return "Platform Event";
322         case IPMI_CMD_GET_PEF_CAPABILITIES:
323           return "Get PEF Capabilities";
324         case IPMI_CMD_ARM_PEF_POSTPONE_TIMER:
325           return "ARM PEF Postpone Timer";
326         case IPMI_CMD_SET_PEF_CONFIGURATION_PARAMETERS:
327           return "Set PEF Configuration Parameters";
328         case IPMI_CMD_GET_PEF_CONFIGURATION_PARAMETERS:
329           return "Get PEF Configuration Parameters";
330         case IPMI_CMD_SET_LAST_PROCESSED_EVENT_ID:
331           return "Set Last Processed Event ID";
332         case IPMI_CMD_GET_LAST_PROCESSED_EVENT_ID:
333           return "Get Last Processed Event ID";
334         case IPMI_CMD_ALERT_IMMEDIATE:
335           return "Alert Immediate";
336         case IPMI_CMD_PET_ACKNOWLEDGE:
337           return "PET Acknowledge";
338         case IPMI_CMD_GET_DEVICE_SDR_INFO:
339           return "Get Device SDR Info";
340         case IPMI_CMD_GET_DEVICE_SDR:
341           return "Get Device SDR";
342         case IPMI_CMD_RESERVE_DEVICE_SDR_REPOSITORY:
343           return "Reserve Device SDR Repository";
344         case IPMI_CMD_GET_SENSOR_READING_FACTORS:
345           return "Get Sensor Reading Factors";
346         case IPMI_CMD_SET_SENSOR_HYSTERESIS:
347           return "Set Sensor Hysteresis";
348         case IPMI_CMD_GET_SENSOR_HYSTERESIS:
349           return "Get Sensor Hysteresis";
350         case IPMI_CMD_SET_SENSOR_THRESHOLDS:
351           return "Set Sensor Thresholds";
352         case IPMI_CMD_GET_SENSOR_THRESHOLDS:
353           return "Get Sensor Thresholds";
354         case IPMI_CMD_SET_SENSOR_EVENT_ENABLE:
355           return "Set Sensor Event Enable";
356         case IPMI_CMD_GET_SENSOR_EVENT_ENABLE:
357           return "Get Sensor Event Enable";
358         case IPMI_CMD_RE_ARM_SENSOR_EVENTS:
359           return "Re-arm Sensor Events";
360         case IPMI_CMD_GET_SENSOR_EVENT_STATUS:
361           return "Get Sensor Event Status";
362         case IPMI_CMD_GET_SENSOR_READING:
363           return "Get Sensor Reading";
364         case IPMI_CMD_SET_SENSOR_TYPE:
365           return "Set Sensor Type";
366         case IPMI_CMD_GET_SENSOR_TYPE:
367           return "Get Sensor Type";
368         case IPMI_CMD_SET_SENSOR_READING_AND_EVENT_STATUS:
369           return "Set Sensor Reading and Event Status";
370         default:
371           return "Unknown";
372         }
373       break;
374     case IPMI_NET_FN_APP_RQ:
375     case IPMI_NET_FN_APP_RS:
376       switch (cmd)
377         {
378         case IPMI_CMD_GET_DEVICE_ID:
379           return "Get Device ID";
380         case IPMI_CMD_COLD_RESET:
381           return "Cold Reset";
382         case IPMI_CMD_WARM_RESET:
383           return "Warm Reset";
384         case IPMI_CMD_GET_SELF_TEST_RESULTS:
385           return "Get Self Test Results";
386         case IPMI_CMD_MANUFACTURING_TEST_ON:
387           return "Manufacturing Test On";
388         case IPMI_CMD_SET_ACPI_POWER_STATE:
389           return "Set ACPI Power State";
390         case IPMI_CMD_GET_ACPI_POWER_STATE:
391           return "Get ACPI Power State";
392         case IPMI_CMD_GET_DEVICE_GUID:
393           return "Get Device GUID";
394         case IPMI_CMD_GET_NETFN_SUPPORT:
395           return "Get NetFN Support";
396         case IPMI_CMD_GET_COMMAND_SUPPORT:
397           return "Get Command Support";
398         case IPMI_CMD_GET_COMMAND_SUB_FUNCTION_SUPPORT:
399           return "Get Command Sub-Function Support";
400         case IPMI_CMD_GET_CONFIGURABLE_COMMANDS:
401           return "Get Configurable Commands";
402         case IPMI_CMD_GET_CONFIGURABLE_COMMAND_SUB_FUNCTIONS:
403           return "Get Configurable Command Sub-Functions";
404         case IPMI_CMD_SET_COMMAND_ENABLES:
405           return "Set Command Enables";
406         case IPMI_CMD_GET_COMMAND_ENABLES:
407           return "Get Command Enables";
408         case IPMI_CMD_SET_COMMAND_SUB_FUNCTION_ENABLES:
409           return "Set Command Sub-Function Enables";
410         case IPMI_CMD_GET_COMMAND_SUB_FUNCTION_ENABLES:
411           return "Get Command Sub-Function Enables";
412         case IPMI_CMD_GET_OEM_NETFN_IANA_SUPPORT:
413           return "Get OEM NetFN IANA Support";
414         case IPMI_CMD_RESET_WATCHDOG_TIMER:
415           return "Reset Watchdog Timer";
416         case IPMI_CMD_SET_WATCHDOG_TIMER:
417           return "Set Watchdog Timer";
418         case IPMI_CMD_GET_WATCHDOG_TIMER:
419           return "Get Watchdog Timer";
420         case IPMI_CMD_SET_BMC_GLOBAL_ENABLES:
421           return "Set BMC Global Enables";
422         case IPMI_CMD_GET_BMC_GLOBAL_ENABLES:
423           return "Get BMC Global Enables";
424         case IPMI_CMD_CLEAR_MESSAGE_FLAGS:
425           return "Clear Message Flags";
426         case IPMI_CMD_GET_MESSAGE_FLAGS:
427           return "Get Message Flags";
428         case IPMI_CMD_ENABLE_MESSAGE_CHANNEL_RECEIVE:
429           return "Enable Message Channel Receive";
430         case IPMI_CMD_GET_MESSAGE:
431           return "Get Message";
432         case IPMI_CMD_SEND_MESSAGE:
433           return "Send Message";
434         case IPMI_CMD_READ_EVENT_MESSAGE_BUFFER:
435           return "Read Event Message Buffer";
436         case IPMI_CMD_GET_BT_INTERFACE_CAPABILITIES:
437           return "Get BT Interface Capabilities";
438         case IPMI_CMD_GET_SYSTEM_GUID:
439           return "Get System GUID";
440         case IPMI_CMD_SET_SYSTEM_INFO_PARAMETERS:
441           return "Set System Info Parameters";
442         case IPMI_CMD_GET_SYSTEM_INFO_PARAMETERS:
443           return "Get System Info Parameters";
444         case IPMI_CMD_GET_CHANNEL_AUTHENTICATION_CAPABILITIES:
445           return "Get Channel Authentication Capabilities";
446         case IPMI_CMD_GET_SESSION_CHALLENGE:
447           return "Get Session Challenge";
448         case IPMI_CMD_ACTIVATE_SESSION:
449           return "Activate Session";
450         case IPMI_CMD_SET_SESSION_PRIVILEGE_LEVEL:
451           return "Set Session Privilege Level";
452         case IPMI_CMD_CLOSE_SESSION:
453           return "Close Session";
454         case IPMI_CMD_GET_SESSION_INFO:
455           return "Get Session Info";
456         case IPMI_CMD_GET_AUTHCODE:
457           return "Get Authcode";
458         case IPMI_CMD_SET_CHANNEL_ACCESS:
459           return "Set Channel Access";
460         case IPMI_CMD_GET_CHANNEL_ACCESS:
461           return "Get Channel Access";
462         case IPMI_CMD_GET_CHANNEL_INFO_COMMAND:
463           return "Get Channel Info Command";
464         case IPMI_CMD_SET_USER_ACCESS_COMMAND:
465           return "Set User Access Command";
466         case IPMI_CMD_GET_USER_ACCESS_COMMAND:
467           return "Get User Access Command";
468         case IPMI_CMD_SET_USER_NAME:
469           return "Set User Name Command"; /* 'Set User Name' in table, added 'Command' for consistency */
470         case IPMI_CMD_GET_USER_NAME_COMMAND:
471           return "Get User Name Command";
472         case IPMI_CMD_SET_USER_PASSWORD_COMMAND:
473           return "Set User Password Command";
474         case IPMI_CMD_ACTIVATE_PAYLOAD:
475           return "Activate Payload";
476         case IPMI_CMD_DEACTIVATE_PAYLOAD:
477           return "Deactivate Payload";
478         case IPMI_CMD_GET_PAYLOAD_ACTIVATION_STATUS:
479           return "Get Payload Activation Status";
480         case IPMI_CMD_GET_PAYLOAD_INSTANCE_INFO:
481           return "Get Payload Instance Info";
482         case IPMI_CMD_SET_USER_PAYLOAD_ACCESS:
483           return "Set User Payload Access";
484         case IPMI_CMD_GET_USER_PAYLOAD_ACCESS:
485           return "Get User Payload Access";
486         case IPMI_CMD_GET_CHANNEL_PAYLOAD_SUPPORT:
487           return "Get Channel Payload Support";
488         case IPMI_CMD_GET_CHANNEL_PAYLOAD_VERSION:
489           return "Get Channel Payload Version";
490         case IPMI_CMD_GET_CHANNEL_OEM_PAYLOAD_INFO:
491           return "Get Channel OEM Payload Info";
492         case IPMI_CMD_MASTER_WRITE_READ:
493           return "Master Write Read";
494         case IPMI_CMD_GET_CHANNEL_CIPHER_SUITES:
495           return "Get Channel Cipher Suites";
496         case IPMI_CMD_SUSPEND_RESUME_PAYLOAD_ENCRYPTION:
497           return "Suspend Resume Payload Encryption";
498         case IPMI_CMD_SET_CHANNEL_SECURITY_KEYS:
499           return "Set Channel Security Keys";
500         case IPMI_CMD_GET_SYSTEM_INTERFACE_CAPABILITIES:
501           return "Get System Interface Capabilities";
502         default:
503           return "Unknown";
504         }
505       break;
506     case IPMI_NET_FN_FIRMWARE_RQ:
507     case IPMI_NET_FN_FIRMWARE_RS:
508       return "Unknown";
509       break;
510     case IPMI_NET_FN_STORAGE_RQ:
511     case IPMI_NET_FN_STORAGE_RS:
512       switch (cmd)
513         {
514         case IPMI_CMD_GET_FRU_INVENTORY_AREA_INFO:
515           return "Get FRU Inventory Area Info";
516         case IPMI_CMD_READ_FRU_DATA:
517           return "Read FRU Data";
518         case IPMI_CMD_WRITE_FRU_DATA:
519           return "Write FRU Data";
520         case IPMI_CMD_GET_SDR_REPOSITORY_INFO:
521           return "Get SDR Repository Info";
522         case IPMI_CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO:
523           return "Get SDR Repository Allocation Info";
524         case IPMI_CMD_RESERVE_SDR_REPOSITORY:
525           return "Reserve SDR Repository";
526         case IPMI_CMD_GET_SDR:
527           return "Get SDR";
528         case IPMI_CMD_ADD_SDR:
529           return "Add SDR";
530         case IPMI_CMD_PARTIAL_ADD_SDR:
531           return "Partial Add SDR";
532         case IPMI_CMD_DELETE_SDR:
533           return "Delete SDR";
534         case IPMI_CMD_CLEAR_SDR_REPOSITORY:
535           return "Clear SDR Repository";
536         case IPMI_CMD_GET_SDR_REPOSITORY_TIME:
537           return "Get SDR Repository Time";
538         case IPMI_CMD_SET_SDR_REPOSITORY_TIME:
539           return "Set SDR Repository Time";
540         case IPMI_CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE:
541           return "Enter SDR Repository Update Mode";
542         case IPMI_CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE:
543           return "Exit SDR Repository Update Mode";
544         case IPMI_CMD_RUN_INITIALIZATION_AGENT:
545           return "Run Initialization Agent";
546         case IPMI_CMD_GET_SEL_INFO:
547           return "Get SEL Info";
548         case IPMI_CMD_GET_SEL_ALLOCATION_INFO:
549           return "Get SEL Allocation Info";
550         case IPMI_CMD_RESERVE_SEL:
551           return "Reserve SEL";
552         case IPMI_CMD_GET_SEL_ENTRY:
553           return "Get SEL Entry";
554         case IPMI_CMD_ADD_SEL_ENTRY:
555           return "Add SEL Entry";
556         case IPMI_CMD_PARTIAL_ADD_SEL_ENTRY:
557           return "Partial Add SEL Entry";
558         case IPMI_CMD_DELETE_SEL_ENTRY:
559           return "Delete SEL Entry";
560         case IPMI_CMD_CLEAR_SEL:
561           return "Clear SEL";
562         case IPMI_CMD_GET_SEL_TIME:
563           return "Get SEL Time";
564         case IPMI_CMD_SET_SEL_TIME:
565           return "Set SEL Time";
566         case IPMI_CMD_GET_AUXILIARY_LOG_STATUS:
567           return "Get Auxiliary Log Status";
568         case IPMI_CMD_SET_AUXILIARY_LOG_STATUS:
569           return "Set Auxiliary Log Status";
570         case IPMI_CMD_GET_SEL_TIME_UTC_OFFSET:
571           return "Get SEL Time UTC Offset";
572         case IPMI_CMD_SET_SEL_TIME_UTC_OFFSET:
573           return "Set SEL Time UTC Offset";
574         default:
575           return "Unknown";
576         }
577       break;
578     case IPMI_NET_FN_TRANSPORT_RQ:
579     case IPMI_NET_FN_TRANSPORT_RS:
580       switch (cmd)
581         {
582         case IPMI_CMD_SET_LAN_CONFIGURATION_PARAMETERS:
583           return "Set LAN Configuration Parameters";
584         case IPMI_CMD_GET_LAN_CONFIGURATION_PARAMETERS:
585           return "Get LAN Configuration Parameters";
586         case IPMI_CMD_SUSPEND_BMC_ARPS:
587           return "Suspend BMC ARPs";
588         case IPMI_CMD_GET_IP_UDP_RMCP_STATISTICS:
589           return "Get IP UDP RMCP Statistics";
590         case IPMI_CMD_SET_SERIAL_MODEM_CONFIGURATION:
591           return "Set Serial Modem Configuration";
592         case IPMI_CMD_GET_SERIAL_MODEM_CONFIGURATION:
593           return "Get Serial Modem Configuration";
594         case IPMI_CMD_SET_SERIAL_MODEM_MUX:
595           return "Set Serial Modem Mux";
596         case IPMI_CMD_GET_TAP_RESPONSE_CODES:
597           return "Get TAP Response Codes";
598         case IPMI_CMD_SET_PPP_UDP_PROXY_TRANSMIT_DATA:
599           return "Set PPP UDP Proxy Transmit Data";
600         case IPMI_CMD_GET_PPP_UDP_PROXY_TRANSMIT_DATA:
601           return "Get PPP UDP Proxy Transmit Data";
602         case IPMI_CMD_SEND_PPP_UDP_PROXY_PACKET:
603           return "Send PPP UDP Proxy Packet";
604         case IPMI_CMD_GET_PPP_UDP_PROXY_RECEIVE_DATA:
605           return "Get PPP UDP Proxy Receive Data";
606         case IPMI_CMD_SERIAL_MODEM_CONNECTION_ACTIVE:
607           return "Serial Modem Connection Active";
608         case IPMI_CMD_CALLBACK:
609           return "Callback";
610         case IPMI_CMD_SET_USER_CALLBACK_OPTIONS:
611           return "Set User Callback Options";
612         case IPMI_CMD_GET_USER_CALLBACK_OPTIONS:
613           return "Get User Callback Options";
614         case IPMI_CMD_SET_SERIAL_ROUTING_MUX:
615           return "Set Serial Routing Mux";
616         case IPMI_CMD_SOL_ACTIVATING:
617           return "SOL Activating";
618         case IPMI_CMD_SET_SOL_CONFIGURATION_PARAMETERS:
619           return "Set SOL Configuration Parameters";
620         case IPMI_CMD_GET_SOL_CONFIGURATION_PARAMETERS:
621           return "Get SOL Configuration Parameters";
622         case IPMI_CMD_FORWARDED_COMMAND:
623           return "Forwarded Command";
624         case IPMI_CMD_SET_FORWARDED_COMMANDS:
625           return "Set Forwarded Commands";
626         case IPMI_CMD_GET_FORWARDED_COMMANDS:
627           return "Get Forwarded Commands";
628         case IPMI_CMD_ENABLE_FORWARDED_COMMANDS:
629           return "Enable Forwarded Commands";
630         default:
631           return "Unknown";
632         }
633       break;
634     default:
635       return "Unknown";
636     }
637 }
638 
639