xref: /openbmc/ipmitool/src/ipmitool.c (revision f1c6118c722ba4f20f3bdb2324503821a33b4e3d)
1c18ec02fSPetter Reinholdtsen /*
2c18ec02fSPetter Reinholdtsen  * Copyright (c) 2005 Sun Microsystems, Inc.  All Rights Reserved.
3c18ec02fSPetter Reinholdtsen  * Use is subject to license terms.
4c18ec02fSPetter Reinholdtsen  */
5c18ec02fSPetter Reinholdtsen 
6c18ec02fSPetter Reinholdtsen /*
7c18ec02fSPetter Reinholdtsen  * Redistribution and use in source and binary forms, with or without
8c18ec02fSPetter Reinholdtsen  * modification, are permitted provided that the following conditions
9c18ec02fSPetter Reinholdtsen  * are met:
10c18ec02fSPetter Reinholdtsen  *
11c18ec02fSPetter Reinholdtsen  * Redistribution of source code must retain the above copyright
12c18ec02fSPetter Reinholdtsen  * notice, this list of conditions and the following disclaimer.
13c18ec02fSPetter Reinholdtsen  *
14c18ec02fSPetter Reinholdtsen  * Redistribution in binary form must reproduce the above copyright
15c18ec02fSPetter Reinholdtsen  * notice, this list of conditions and the following disclaimer in the
16c18ec02fSPetter Reinholdtsen  * documentation and/or other materials provided with the distribution.
17c18ec02fSPetter Reinholdtsen  *
18c18ec02fSPetter Reinholdtsen  * Neither the name of Sun Microsystems, Inc. or the names of
19c18ec02fSPetter Reinholdtsen  * contributors may be used to endorse or promote products derived
20c18ec02fSPetter Reinholdtsen  * from this software without specific prior written permission.
21c18ec02fSPetter Reinholdtsen  *
22c18ec02fSPetter Reinholdtsen  * This software is provided "AS IS," without a warranty of any kind.
23c18ec02fSPetter Reinholdtsen  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
24c18ec02fSPetter Reinholdtsen  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
25c18ec02fSPetter Reinholdtsen  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
26c18ec02fSPetter Reinholdtsen  * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
27c18ec02fSPetter Reinholdtsen  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
28c18ec02fSPetter Reinholdtsen  * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT WILL
29c18ec02fSPetter Reinholdtsen  * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
30c18ec02fSPetter Reinholdtsen  * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
31c18ec02fSPetter Reinholdtsen  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
32c18ec02fSPetter Reinholdtsen  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
33c18ec02fSPetter Reinholdtsen  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
34c18ec02fSPetter Reinholdtsen  */
35c18ec02fSPetter Reinholdtsen 
36c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi.h>
37c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_intf.h>
38c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_main.h>
39c18ec02fSPetter Reinholdtsen 
40c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_sdr.h>
41c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_gendev.h>
42c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_sel.h>
43c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_fru.h>
44c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_sol.h>
45c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_isol.h>
46c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_tsol.h>
47c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_lanp.h>
48c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_chassis.h>
49c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_mc.h>
50c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_sensor.h>
51c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_channel.h>
52c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_session.h>
53c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_event.h>
54c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_user.h>
55c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_raw.h>
56c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_pef.h>
57c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_oem.h>
58c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_sunoem.h>
59c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_fwum.h>
60c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_picmg.h>
61c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_kontronoem.h>
62c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_firewall.h>
63c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_hpmfwupg.h>
64c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_delloem.h>
65c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_ekanalyzer.h>
66c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_ime.h>
67c18ec02fSPetter Reinholdtsen #include <ipmitool/ipmi_dcmi.h>
68*f1c6118cSZdenek Styblik #include <ipmitool/ipmi_vita.h>
69c18ec02fSPetter Reinholdtsen 
70c18ec02fSPetter Reinholdtsen #ifdef HAVE_CONFIG_H
71c18ec02fSPetter Reinholdtsen # include <config.h>
72c18ec02fSPetter Reinholdtsen #endif
73c18ec02fSPetter Reinholdtsen 
74c18ec02fSPetter Reinholdtsen #ifdef HAVE_READLINE
75c18ec02fSPetter Reinholdtsen extern int ipmi_shell_main(struct ipmi_intf * intf, int argc, char ** argv);
76c18ec02fSPetter Reinholdtsen #endif
77c18ec02fSPetter Reinholdtsen extern int ipmi_echo_main(struct ipmi_intf * intf, int argc, char ** argv);
78c18ec02fSPetter Reinholdtsen extern int ipmi_set_main(struct ipmi_intf * intf, int argc, char ** argv);
79c18ec02fSPetter Reinholdtsen extern int ipmi_exec_main(struct ipmi_intf * intf, int argc, char ** argv);
80c18ec02fSPetter Reinholdtsen 
81c18ec02fSPetter Reinholdtsen 
82c18ec02fSPetter Reinholdtsen int csv_output = 0;
83c18ec02fSPetter Reinholdtsen int verbose = 0;
84c18ec02fSPetter Reinholdtsen 
85c18ec02fSPetter Reinholdtsen struct ipmi_cmd ipmitool_cmd_list[] = {
86c18ec02fSPetter Reinholdtsen 	{ ipmi_raw_main,     "raw",     "Send a RAW IPMI request and print response" },
87c18ec02fSPetter Reinholdtsen 	{ ipmi_rawi2c_main,  "i2c",     "Send an I2C Master Write-Read command and print response" },
88c18ec02fSPetter Reinholdtsen 	{ ipmi_rawspd_main,  "spd",     "Print SPD info from remote I2C device" },
89c18ec02fSPetter Reinholdtsen 	{ ipmi_lanp_main,    "lan",     "Configure LAN Channels" },
90c18ec02fSPetter Reinholdtsen 	{ ipmi_chassis_main, "chassis", "Get chassis status and set power state" },
91c18ec02fSPetter Reinholdtsen 	{ ipmi_power_main,   "power",   "Shortcut to chassis power commands" },
92c18ec02fSPetter Reinholdtsen 	{ ipmi_event_main,   "event",   "Send pre-defined events to MC" },
93c18ec02fSPetter Reinholdtsen 	{ ipmi_mc_main,      "mc",      "Management Controller status and global enables" },
94c18ec02fSPetter Reinholdtsen 	{ ipmi_mc_main,      "bmc",     NULL },	/* for backwards compatibility */
95c18ec02fSPetter Reinholdtsen 	{ ipmi_sdr_main,     "sdr",     "Print Sensor Data Repository entries and readings" },
96c18ec02fSPetter Reinholdtsen 	{ ipmi_sensor_main,  "sensor",  "Print detailed sensor information" },
97c18ec02fSPetter Reinholdtsen 	{ ipmi_fru_main,     "fru",     "Print built-in FRU and scan SDR for FRU locators" },
98c18ec02fSPetter Reinholdtsen 	{ ipmi_gendev_main,  "gendev",  "Read/Write Device associated with Generic Device locators sdr" },
99c18ec02fSPetter Reinholdtsen 	{ ipmi_sel_main,     "sel",     "Print System Event Log (SEL)" },
100c18ec02fSPetter Reinholdtsen 	{ ipmi_pef_main,     "pef",     "Configure Platform Event Filtering (PEF)" },
101c18ec02fSPetter Reinholdtsen 	{ ipmi_sol_main,     "sol",     "Configure and connect IPMIv2.0 Serial-over-LAN" },
102c18ec02fSPetter Reinholdtsen 	{ ipmi_tsol_main,    "tsol",    "Configure and connect with Tyan IPMIv1.5 Serial-over-LAN" },
103c18ec02fSPetter Reinholdtsen 	{ ipmi_isol_main,    "isol",    "Configure IPMIv1.5 Serial-over-LAN" },
104c18ec02fSPetter Reinholdtsen 	{ ipmi_user_main,    "user",    "Configure Management Controller users" },
105c18ec02fSPetter Reinholdtsen 	{ ipmi_channel_main, "channel", "Configure Management Controller channels" },
106c18ec02fSPetter Reinholdtsen 	{ ipmi_session_main, "session", "Print session information" },
107c18ec02fSPetter Reinholdtsen 	{ ipmi_dcmi_main,    "dcmi",    "Data Center Management Interface"},
108fd5fdc59SPat Donlin 	{ ipmi_nm_main,      "nm",      "Node Manager Interface"},
109c18ec02fSPetter Reinholdtsen 	{ ipmi_sunoem_main,  "sunoem",  "OEM Commands for Sun servers" },
110c18ec02fSPetter Reinholdtsen 	{ ipmi_kontronoem_main, "kontronoem", "OEM Commands for Kontron devices"},
111c18ec02fSPetter Reinholdtsen 	{ ipmi_picmg_main,   "picmg",   "Run a PICMG/ATCA extended cmd"},
112c18ec02fSPetter Reinholdtsen 	{ ipmi_fwum_main,    "fwum",	"Update IPMC using Kontron OEM Firmware Update Manager" },
113c18ec02fSPetter Reinholdtsen 	{ ipmi_firewall_main,"firewall","Configure Firmware Firewall" },
114c18ec02fSPetter Reinholdtsen 	{ ipmi_delloem_main, "delloem", "OEM Commands for Dell systems" },
115c18ec02fSPetter Reinholdtsen #ifdef HAVE_READLINE
116c18ec02fSPetter Reinholdtsen 	{ ipmi_shell_main,   "shell",   "Launch interactive IPMI shell" },
117c18ec02fSPetter Reinholdtsen #endif
118c18ec02fSPetter Reinholdtsen 	{ ipmi_exec_main,    "exec",    "Run list of commands from file" },
119c18ec02fSPetter Reinholdtsen 	{ ipmi_set_main,     "set",     "Set runtime variable for shell and exec" },
120c18ec02fSPetter Reinholdtsen 	{ ipmi_echo_main,    "echo",    NULL }, /* for echoing lines to stdout in scripts */
121c18ec02fSPetter Reinholdtsen 	{ ipmi_hpmfwupg_main,"hpm", "Update HPM components using PICMG HPM.1 file"},
122c18ec02fSPetter Reinholdtsen 	{ ipmi_ekanalyzer_main,"ekanalyzer", "run FRU-Ekeying analyzer using FRU files"},
123c18ec02fSPetter Reinholdtsen 	{ ipmi_ime_main,          "ime", "Update Intel Manageability Engine Firmware"},
124*f1c6118cSZdenek Styblik 	{ ipmi_vita_main,   "vita",   "Run a VITA 46.11 extended cmd"},
125c18ec02fSPetter Reinholdtsen 	{ NULL },
126c18ec02fSPetter Reinholdtsen };
127c18ec02fSPetter Reinholdtsen 
128c18ec02fSPetter Reinholdtsen int
main(int argc,char ** argv)129c18ec02fSPetter Reinholdtsen main(int argc, char ** argv)
130c18ec02fSPetter Reinholdtsen {
131c18ec02fSPetter Reinholdtsen 	int rc;
132c18ec02fSPetter Reinholdtsen 
133c18ec02fSPetter Reinholdtsen 	rc = ipmi_main(argc, argv, ipmitool_cmd_list, NULL);
134c18ec02fSPetter Reinholdtsen 
135c18ec02fSPetter Reinholdtsen 	if (rc < 0)
136c18ec02fSPetter Reinholdtsen 		exit(EXIT_FAILURE);
137c18ec02fSPetter Reinholdtsen 	else
138c18ec02fSPetter Reinholdtsen 		exit(EXIT_SUCCESS);
139c18ec02fSPetter Reinholdtsen }
140