blob: fd58218dd60c3d9b0f75dec85f9284ff3c6f4e4e [file] [log] [blame]
Patrick Venture46470a32018-09-07 19:26:25 -07001#include "apphandler.hpp"
Patrick Venture0b02be92018-08-31 11:55:55 -07002
Xo Wangf542e8b2017-08-09 15:34:16 -07003#include "app/channel.hpp"
4#include "app/watchdog.hpp"
5#include "ipmid.hpp"
Xo Wangf542e8b2017-08-09 15:34:16 -07006#include "sys_info_param.hpp"
7#include "transporthandler.hpp"
8#include "types.hpp"
9#include "utils.hpp"
10
Patrick Venture0b02be92018-08-31 11:55:55 -070011#include <arpa/inet.h>
Patrick Venture46470a32018-09-07 19:26:25 -070012#include <host-ipmid/ipmid-api.h>
Xo Wang87651332017-08-11 10:17:59 -070013#include <limits.h>
Patrick Venture0b02be92018-08-31 11:55:55 -070014#include <mapper.h>
Patrick Venture0b02be92018-08-31 11:55:55 -070015#include <systemd/sd-bus.h>
Xo Wang87651332017-08-11 10:17:59 -070016#include <unistd.h>
Patrick Venture0b02be92018-08-31 11:55:55 -070017
Patrick Venture3a5071a2018-09-12 13:27:42 -070018#include <algorithm>
19#include <array>
20#include <cstddef>
21#include <fstream>
22#include <memory>
Patrick Venture46470a32018-09-07 19:26:25 -070023#include <nlohmann/json.hpp>
Patrick Venture3a5071a2018-09-12 13:27:42 -070024#include <phosphor-logging/elog-errors.hpp>
25#include <phosphor-logging/log.hpp>
William A. Kennington III4c008022018-10-12 17:18:14 -070026#include <sdbusplus/message/types.hpp>
Patrick Venture3a5071a2018-09-12 13:27:42 -070027#include <string>
28#include <tuple>
29#include <vector>
30#include <xyz/openbmc_project/Common/error.hpp>
31#include <xyz/openbmc_project/Software/Activation/server.hpp>
32#include <xyz/openbmc_project/Software/Version/server.hpp>
33#include <xyz/openbmc_project/State/BMC/server.hpp>
Ratan Guptab8e99552017-07-27 07:07:48 +053034
Vernon Mauery185b9f82018-07-20 10:52:36 -070035#if __has_include(<filesystem>)
36#include <filesystem>
37#elif __has_include(<experimental/filesystem>)
38#include <experimental/filesystem>
Patrick Venture0b02be92018-08-31 11:55:55 -070039namespace std
40{
41// splice experimental::filesystem into std
42namespace filesystem = std::experimental::filesystem;
43} // namespace std
Vernon Mauery185b9f82018-07-20 10:52:36 -070044#else
Patrick Venture0b02be92018-08-31 11:55:55 -070045#error filesystem not available
Vernon Mauery185b9f82018-07-20 10:52:36 -070046#endif
Ratan Gupta62736ec2017-09-02 12:02:47 +053047
Patrick Venture0b02be92018-08-31 11:55:55 -070048extern sd_bus* bus;
vishwabmcba0bd5f2015-09-30 16:50:23 +053049
Alexander Amelkinba19c182018-09-04 15:49:36 +030050constexpr auto bmc_state_interface = "xyz.openbmc_project.State.BMC";
51constexpr auto bmc_state_property = "CurrentBMCState";
Marri Devender Rao5e007a52018-01-08 06:18:36 -060052constexpr auto bmc_interface = "xyz.openbmc_project.Inventory.Item.Bmc";
53constexpr auto bmc_guid_interface = "xyz.openbmc_project.Common.UUID";
54constexpr auto bmc_guid_property = "UUID";
55constexpr auto bmc_guid_len = 16;
56
Nagaraju Goruganti744398d2018-02-20 09:52:00 -060057static constexpr auto redundancyIntf =
58 "xyz.openbmc_project.Software.RedundancyPriority";
Patrick Venture0b02be92018-08-31 11:55:55 -070059static constexpr auto versionIntf = "xyz.openbmc_project.Software.Version";
Nagaraju Goruganti744398d2018-02-20 09:52:00 -060060static constexpr auto activationIntf =
61 "xyz.openbmc_project.Software.Activation";
62static constexpr auto softwareRoot = "/xyz/openbmc_project/software";
63
Chris Austen6caf28b2015-10-13 12:40:40 -050064void register_netfn_app_functions() __attribute__((constructor));
vishwabmcba0bd5f2015-09-30 16:50:23 +053065
Ratan Guptab8e99552017-07-27 07:07:48 +053066using namespace phosphor::logging;
67using namespace sdbusplus::xyz::openbmc_project::Common::Error;
Nagaraju Goruganti744398d2018-02-20 09:52:00 -060068using Version = sdbusplus::xyz::openbmc_project::Software::server::Version;
69using Activation =
70 sdbusplus::xyz::openbmc_project::Software::server::Activation;
Alexander Amelkinba19c182018-09-04 15:49:36 +030071using BMC = sdbusplus::xyz::openbmc_project::State::server::BMC;
Vernon Mauery185b9f82018-07-20 10:52:36 -070072namespace fs = std::filesystem;
William A. Kennington III4c008022018-10-12 17:18:14 -070073namespace variant_ns = sdbusplus::message::variant_ns;
Ratan Guptab8e99552017-07-27 07:07:48 +053074
Nan Liee0cb902016-07-11 15:38:03 +080075// Offset in get device id command.
76typedef struct
77{
Patrick Venture0b02be92018-08-31 11:55:55 -070078 uint8_t id;
79 uint8_t revision;
80 uint8_t fw[2];
81 uint8_t ipmi_ver;
82 uint8_t addn_dev_support;
83 uint8_t manuf_id[3];
84 uint8_t prod_id[2];
85 uint8_t aux[4];
86} __attribute__((packed)) ipmi_device_id_t;
Chris Austen7303bdc2016-04-17 11:50:54 -050087
Nagaraju Goruganti744398d2018-02-20 09:52:00 -060088/**
89 * @brief Returns the Version info from primary s/w object
90 *
91 * Get the Version info from the active s/w object which is having high
92 * "Priority" value(a smaller number is a higher priority) and "Purpose"
93 * is "BMC" from the list of all s/w objects those are implementing
94 * RedundancyPriority interface from the given softwareRoot path.
95 *
96 * @return On success returns the Version info from primary s/w object.
97 *
98 */
99std::string getActiveSoftwareVersionInfo()
100{
101 sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
102
103 std::string revision{};
Patrick Venture0b02be92018-08-31 11:55:55 -0700104 auto objectTree =
105 ipmi::getAllDbusObjects(bus, softwareRoot, redundancyIntf, "");
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600106 if (objectTree.empty())
107 {
108 log<level::ERR>("No Obj has implemented the s/w redundancy interface",
109 entry("INTERFACE=%s", redundancyIntf));
110 elog<InternalFailure>();
111 }
112
113 auto objectFound = false;
114 for (auto& softObject : objectTree)
115 {
116 auto service = ipmi::getService(bus, redundancyIntf, softObject.first);
117 auto objValueTree = ipmi::getManagedObjects(bus, service, softwareRoot);
118
119 auto minPriority = 0xFF;
120 for (const auto& objIter : objValueTree)
121 {
122 try
123 {
124 auto& intfMap = objIter.second;
125 auto& redundancyPriorityProps = intfMap.at(redundancyIntf);
126 auto& versionProps = intfMap.at(versionIntf);
127 auto& activationProps = intfMap.at(activationIntf);
William A. Kennington III4c008022018-10-12 17:18:14 -0700128 auto priority = variant_ns::get<uint8_t>(
129 redundancyPriorityProps.at("Priority"));
130 auto purpose =
131 variant_ns::get<std::string>(versionProps.at("Purpose"));
132 auto activation = variant_ns::get<std::string>(
133 activationProps.at("Activation"));
134 auto version =
135 variant_ns::get<std::string>(versionProps.at("Version"));
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600136 if ((Version::convertVersionPurposeFromString(purpose) ==
137 Version::VersionPurpose::BMC) &&
138 (Activation::convertActivationsFromString(activation) ==
139 Activation::Activations::Active))
140 {
141 if (priority < minPriority)
142 {
143 minPriority = priority;
144 objectFound = true;
145 revision = std::move(version);
146 }
147 }
148 }
149 catch (const std::exception& e)
150 {
151 log<level::ERR>(e.what());
152 }
153 }
154 }
155
156 if (!objectFound)
157 {
158 log<level::ERR>("Could not found an BMC software Object");
159 elog<InternalFailure>();
160 }
161
162 return revision;
163}
164
Alexander Amelkinba19c182018-09-04 15:49:36 +0300165bool getCurrentBmcState()
166{
167 sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
168
169 // Get the Inventory object implementing the BMC interface
170 ipmi::DbusObjectInfo bmcObject =
171 ipmi::getDbusObject(bus, bmc_state_interface);
172 auto variant =
173 ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first,
174 bmc_state_interface, bmc_state_property);
175
William A. Kennington III4c008022018-10-12 17:18:14 -0700176 return variant_ns::holds_alternative<std::string>(variant) &&
177 BMC::convertBMCStateFromString(
178 variant_ns::get<std::string>(variant)) == BMC::BMCState::Ready;
Alexander Amelkinba19c182018-09-04 15:49:36 +0300179}
180
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500181ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700182 ipmi_request_t request,
183 ipmi_response_t response,
184 ipmi_data_len_t data_len,
185 ipmi_context_t context)
Chris Austen6caf28b2015-10-13 12:40:40 -0500186{
187 ipmi_ret_t rc = IPMI_CC_OK;
188 *data_len = 0;
189
Aditya Saripalli5fb14602017-11-09 14:46:27 +0530190 log<level::DEBUG>("IPMI SET ACPI STATE Ignoring for now\n");
Chris Austen6caf28b2015-10-13 12:40:40 -0500191 return rc;
192}
193
Chris Austen7303bdc2016-04-17 11:50:54 -0500194typedef struct
195{
196 char major;
197 char minor;
Chris Austen176c9652016-04-30 16:32:17 -0500198 uint16_t d[2];
Chris Austen7303bdc2016-04-17 11:50:54 -0500199} rev_t;
200
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600201/* Currently supports the vx.x-x-[-x] and v1.x.x-x-[-x] format. It will */
202/* return -1 if not in those formats, this routine knows how to parse */
Chris Austen7303bdc2016-04-17 11:50:54 -0500203/* version = v0.6-19-gf363f61-dirty */
204/* ^ ^ ^^ ^ */
205/* | | |----------|-- additional details */
206/* | |---------------- Minor */
207/* |------------------ Major */
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600208/* and version = v1.99.10-113-g65edf7d-r3-0-g9e4f715 */
209/* ^ ^ ^^ ^ */
210/* | | |--|---------- additional details */
211/* | |---------------- Minor */
212/* |------------------ Major */
Chris Austen7303bdc2016-04-17 11:50:54 -0500213/* Additional details : If the option group exists it will force Auxiliary */
214/* Firmware Revision Information 4th byte to 1 indicating the build was */
215/* derived with additional edits */
Patrick Venture0b02be92018-08-31 11:55:55 -0700216int convert_version(const char* p, rev_t* rev)
Chris Austen7303bdc2016-04-17 11:50:54 -0500217{
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600218 std::string s(p);
219 std::string token;
Chris Austen176c9652016-04-30 16:32:17 -0500220 uint16_t commits;
Chris Austen7303bdc2016-04-17 11:50:54 -0500221
Patrick Venture0b02be92018-08-31 11:55:55 -0700222 auto location = s.find_first_of('v');
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600223 if (location != std::string::npos)
224 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700225 s = s.substr(location + 1);
Chris Austen176c9652016-04-30 16:32:17 -0500226 }
Chris Austen7303bdc2016-04-17 11:50:54 -0500227
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600228 if (!s.empty())
229 {
230 location = s.find_first_of(".");
231 if (location != std::string::npos)
232 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700233 rev->major =
234 static_cast<char>(std::stoi(s.substr(0, location), 0, 16));
235 token = s.substr(location + 1);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600236 }
Chris Austen176c9652016-04-30 16:32:17 -0500237
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600238 if (!token.empty())
239 {
240 location = token.find_first_of(".-");
241 if (location != std::string::npos)
242 {
Patrick Ventured2117022018-02-06 08:54:37 -0800243 rev->minor = static_cast<char>(
Patrick Venture0b02be92018-08-31 11:55:55 -0700244 std::stoi(token.substr(0, location), 0, 16));
245 token = token.substr(location + 1);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600246 }
247 }
Chris Austen7303bdc2016-04-17 11:50:54 -0500248
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600249 // Capture the number of commits on top of the minor tag.
250 // I'm using BE format like the ipmi spec asked for
251 location = token.find_first_of(".-");
252 if (!token.empty())
253 {
254 commits = std::stoi(token.substr(0, location), 0, 16);
Patrick Venture0b02be92018-08-31 11:55:55 -0700255 rev->d[0] = (commits >> 8) | (commits << 8);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600256
257 // commit number we skip
258 location = token.find_first_of(".-");
259 if (location != std::string::npos)
260 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700261 token = token.substr(location + 1);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600262 }
263 }
Patrick Venture0b02be92018-08-31 11:55:55 -0700264 else
265 {
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600266 rev->d[0] = 0;
267 }
268
269 if (location != std::string::npos)
270 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700271 token = token.substr(location + 1);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600272 }
273
274 // Any value of the optional parameter forces it to 1
275 location = token.find_first_of(".-");
276 if (location != std::string::npos)
277 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700278 token = token.substr(location + 1);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600279 }
280 commits = (!token.empty()) ? 1 : 0;
281
Patrick Venture0b02be92018-08-31 11:55:55 -0700282 // We do this operation to get this displayed in least significant bytes
283 // of ipmitool device id command.
284 rev->d[1] = (commits >> 8) | (commits << 8);
Dinesh Chinari2b7e07d2017-11-08 15:38:50 -0600285 }
286
Chris Austen7303bdc2016-04-17 11:50:54 -0500287 return 0;
288}
289
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500290ipmi_ret_t ipmi_app_get_device_id(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700291 ipmi_request_t request,
292 ipmi_response_t response,
293 ipmi_data_len_t data_len,
294 ipmi_context_t context)
Chris Austen6caf28b2015-10-13 12:40:40 -0500295{
296 ipmi_ret_t rc = IPMI_CC_OK;
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600297 int r = -1;
Chris Austen7303bdc2016-04-17 11:50:54 -0500298 rev_t rev = {0};
David Cobbleya1adb072017-11-21 15:58:13 -0800299 static ipmi_device_id_t dev_id{};
300 static bool dev_id_initialized = false;
301 const char* filename = "/usr/share/ipmi-providers/dev_id.json";
Alexander Amelkinba19c182018-09-04 15:49:36 +0300302 constexpr auto ipmiDevIdStateShift = 7;
303 constexpr auto ipmiDevIdFw1Mask = ~(1 << ipmiDevIdStateShift);
Chris Austen6caf28b2015-10-13 12:40:40 -0500304
305 // Data length
Chris Austen7303bdc2016-04-17 11:50:54 -0500306 *data_len = sizeof(dev_id);
307
David Cobbleya1adb072017-11-21 15:58:13 -0800308 if (!dev_id_initialized)
309 {
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600310 try
311 {
312 auto version = getActiveSoftwareVersionInfo();
313 r = convert_version(version.c_str(), &rev);
David Cobbleya1adb072017-11-21 15:58:13 -0800314 }
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600315 catch (const std::exception& e)
316 {
317 log<level::ERR>(e.what());
318 }
Nan Liee0cb902016-07-11 15:38:03 +0800319
Patrick Venture0b02be92018-08-31 11:55:55 -0700320 if (r >= 0)
321 {
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600322 // bit7 identifies if the device is available
323 // 0=normal operation
324 // 1=device firmware, SDR update,
325 // or self-initialization in progress.
Alexander Amelkinba19c182018-09-04 15:49:36 +0300326 // The availability may change in run time, so mask here
327 // and initialize later.
328 dev_id.fw[0] = rev.major & ipmiDevIdFw1Mask;
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600329
330 rev.minor = (rev.minor > 99 ? 99 : rev.minor);
331 dev_id.fw[1] = rev.minor % 10 + (rev.minor / 10) * 16;
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700332 std::memcpy(&dev_id.aux, rev.d, 4);
David Cobbleya1adb072017-11-21 15:58:13 -0800333 }
Nan Liee0cb902016-07-11 15:38:03 +0800334
David Cobbleya1adb072017-11-21 15:58:13 -0800335 // IPMI Spec version 2.0
336 dev_id.ipmi_ver = 2;
Adriana Kobylak0e912642016-06-22 16:54:39 -0500337
David Cobbleya1adb072017-11-21 15:58:13 -0800338 std::ifstream dev_id_file(filename);
339 if (dev_id_file.is_open())
340 {
341 auto data = nlohmann::json::parse(dev_id_file, nullptr, false);
342 if (!data.is_discarded())
343 {
344 dev_id.id = data.value("id", 0);
345 dev_id.revision = data.value("revision", 0);
346 dev_id.addn_dev_support = data.value("addn_dev_support", 0);
347 dev_id.manuf_id[2] = data.value("manuf_id", 0) >> 16;
348 dev_id.manuf_id[1] = data.value("manuf_id", 0) >> 8;
349 dev_id.manuf_id[0] = data.value("manuf_id", 0);
350 dev_id.prod_id[1] = data.value("prod_id", 0) >> 8;
351 dev_id.prod_id[0] = data.value("prod_id", 0);
Tom Josephaf8a0982018-03-09 07:54:02 -0600352 dev_id.aux[3] = data.value("aux", 0);
353 dev_id.aux[2] = data.value("aux", 0) >> 8;
354 dev_id.aux[1] = data.value("aux", 0) >> 16;
355 dev_id.aux[0] = data.value("aux", 0) >> 24;
David Cobbleya1adb072017-11-21 15:58:13 -0800356
Patrick Venture0b02be92018-08-31 11:55:55 -0700357 // Don't read the file every time if successful
David Cobbleya1adb072017-11-21 15:58:13 -0800358 dev_id_initialized = true;
359 }
360 else
361 {
362 log<level::ERR>("Device ID JSON parser failure");
363 rc = IPMI_CC_UNSPECIFIED_ERROR;
364 }
365 }
366 else
367 {
368 log<level::ERR>("Device ID file not found");
369 rc = IPMI_CC_UNSPECIFIED_ERROR;
Chris Austen7303bdc2016-04-17 11:50:54 -0500370 }
371 }
Chris Austen6caf28b2015-10-13 12:40:40 -0500372
Alexander Amelkinba19c182018-09-04 15:49:36 +0300373 // Set availability to the actual current BMC state
374 dev_id.fw[0] &= ipmiDevIdFw1Mask;
375 if (!getCurrentBmcState())
376 {
377 dev_id.fw[0] |= (1 << ipmiDevIdStateShift);
378 }
379
Chris Austen6caf28b2015-10-13 12:40:40 -0500380 // Pack the actual response
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700381 std::memcpy(response, &dev_id, *data_len);
Nagaraju Goruganti744398d2018-02-20 09:52:00 -0600382
Chris Austen6caf28b2015-10-13 12:40:40 -0500383 return rc;
384}
385
Nan Li41fa24a2016-11-10 20:12:37 +0800386ipmi_ret_t ipmi_app_get_self_test_results(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700387 ipmi_request_t request,
388 ipmi_response_t response,
389 ipmi_data_len_t data_len,
390 ipmi_context_t context)
Nan Li41fa24a2016-11-10 20:12:37 +0800391{
392 ipmi_ret_t rc = IPMI_CC_OK;
393
394 // Byte 2:
395 // 55h - No error.
Gunnar Mills8991dd62017-10-25 17:11:29 -0500396 // 56h - Self Test function not implemented in this controller.
Nan Li41fa24a2016-11-10 20:12:37 +0800397 // 57h - Corrupted or inaccesssible data or devices.
398 // 58h - Fatal hardware error.
399 // FFh - reserved.
400 // all other: Device-specific 'internal failure'.
401 // Byte 3:
402 // For byte 2 = 55h, 56h, FFh: 00h
403 // For byte 2 = 58h, all other: Device-specific
404 // For byte 2 = 57h: self-test error bitfield.
405 // Note: returning 57h does not imply that all test were run.
406 // [7] 1b = Cannot access SEL device.
407 // [6] 1b = Cannot access SDR Repository.
408 // [5] 1b = Cannot access BMC FRU device.
409 // [4] 1b = IPMB signal lines do not respond.
410 // [3] 1b = SDR Repository empty.
411 // [2] 1b = Internal Use Area of BMC FRU corrupted.
412 // [1] 1b = controller update 'boot block' firmware corrupted.
413 // [0] 1b = controller operational firmware corrupted.
414
415 char selftestresults[2] = {0};
416
417 *data_len = 2;
418
419 selftestresults[0] = 0x56;
420 selftestresults[1] = 0;
421
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700422 std::memcpy(response, selftestresults, *data_len);
Nan Li41fa24a2016-11-10 20:12:37 +0800423
424 return rc;
425}
426
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500427ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700428 ipmi_request_t request,
429 ipmi_response_t response,
430 ipmi_data_len_t data_len,
431 ipmi_context_t context)
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500432{
Patrick Venture0b02be92018-08-31 11:55:55 -0700433 const char* objname = "/org/openbmc/control/chassis0";
434 const char* iface = "org.freedesktop.DBus.Properties";
435 const char* chassis_iface = "org.openbmc.control.Chassis";
436 sd_bus_message* reply = NULL;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500437 sd_bus_error error = SD_BUS_ERROR_NULL;
438 int r = 0;
Patrick Venture0b02be92018-08-31 11:55:55 -0700439 char* uuid = NULL;
440 char* busname = NULL;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500441
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500442 // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223
Patrick Ventured2117022018-02-06 08:54:37 -0800443 // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte
444 // order
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500445 // Ex: 0x2332fc2c40e66298e511f2782395a361
446
Patrick Venture0b02be92018-08-31 11:55:55 -0700447 const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500448 uint8_t resp_uuid[resp_size]; // Array to hold the formatted response
Patrick Ventured2117022018-02-06 08:54:37 -0800449 // Point resp end of array to save in reverse order
Patrick Venture0b02be92018-08-31 11:55:55 -0700450 int resp_loc = resp_size - 1;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500451 int i = 0;
Patrick Venture0b02be92018-08-31 11:55:55 -0700452 char* tokptr = NULL;
453 char* id_octet = NULL;
Emily Shafferedb8bb02018-09-27 14:50:15 -0700454 size_t total_uuid_size = 0;
455 // 1 byte of resp is built from 2 chars of uuid.
456 constexpr size_t max_uuid_size = 2 * resp_size;
vishwa1eaea4f2016-02-26 11:57:40 -0600457
458 // Status code.
459 ipmi_ret_t rc = IPMI_CC_OK;
460 *data_len = 0;
461
vishwa1eaea4f2016-02-26 11:57:40 -0600462 // Call Get properties method with the interface and property name
Sergey Solomineb9b8142016-08-23 09:07:28 -0500463 r = mapper_get_service(bus, objname, &busname);
Patrick Venture0b02be92018-08-31 11:55:55 -0700464 if (r < 0)
465 {
466 log<level::ERR>("Failed to get bus name", entry("BUS=%s", objname),
Aditya Saripalli5fb14602017-11-09 14:46:27 +0530467 entry("ERRNO=0x%X", -r));
Sergey Solomineb9b8142016-08-23 09:07:28 -0500468 goto finish;
469 }
Patrick Venture0b02be92018-08-31 11:55:55 -0700470 r = sd_bus_call_method(bus, busname, objname, iface, "Get", &error, &reply,
471 "ss", chassis_iface, "uuid");
vishwa1eaea4f2016-02-26 11:57:40 -0600472 if (r < 0)
473 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700474 log<level::ERR>("Failed to call Get Method", entry("ERRNO=0x%X", -r));
vishwa1eaea4f2016-02-26 11:57:40 -0600475 rc = IPMI_CC_UNSPECIFIED_ERROR;
476 goto finish;
477 }
478
479 r = sd_bus_message_read(reply, "v", "s", &uuid);
480 if (r < 0 || uuid == NULL)
481 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700482 log<level::ERR>("Failed to get a response", entry("ERRNO=0x%X", -r));
vishwa1eaea4f2016-02-26 11:57:40 -0600483 rc = IPMI_CC_RESPONSE_ERROR;
484 goto finish;
485 }
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500486
487 // Traverse the UUID
Patrick Ventured2117022018-02-06 08:54:37 -0800488 // Get the UUID octects separated by dash
489 id_octet = strtok_r(uuid, "-", &tokptr);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500490
491 if (id_octet == NULL)
vishwa1eaea4f2016-02-26 11:57:40 -0600492 {
493 // Error
Patrick Venture0b02be92018-08-31 11:55:55 -0700494 log<level::ERR>("Unexpected UUID format", entry("UUID=%s", uuid));
vishwa1eaea4f2016-02-26 11:57:40 -0600495 rc = IPMI_CC_RESPONSE_ERROR;
496 goto finish;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500497 }
498
499 while (id_octet != NULL)
500 {
501 // Calculate the octet string size since it varies
502 // Divide it by 2 for the array size since 1 byte is built from 2 chars
Patrick Venture0b02be92018-08-31 11:55:55 -0700503 int tmp_size = strlen(id_octet) / 2;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500504
Emily Shafferedb8bb02018-09-27 14:50:15 -0700505 // Check if total UUID size has been exceeded
506 if ((total_uuid_size += strlen(id_octet)) > max_uuid_size)
507 {
508 // Error - UUID too long to store
509 log<level::ERR>("UUID too long", entry("UUID=%s", uuid));
510 rc = IPMI_CC_RESPONSE_ERROR;
511 goto finish;
512 }
513
Patrick Venture0b02be92018-08-31 11:55:55 -0700514 for (i = 0; i < tmp_size; i++)
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500515 {
Patrick Ventured2117022018-02-06 08:54:37 -0800516 // Holder of the 2 chars that will become a byte
517 char tmp_array[3] = {0};
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500518 strncpy(tmp_array, id_octet, 2); // 2 chars at a time
519
520 int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
Patrick Ventured2117022018-02-06 08:54:37 -0800521 // Copy end to first
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700522 std::memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500523 resp_loc--;
Patrick Venture0b02be92018-08-31 11:55:55 -0700524 id_octet += 2; // Finished with the 2 chars, advance
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500525 }
Patrick Venture0b02be92018-08-31 11:55:55 -0700526 id_octet = strtok_r(NULL, "-", &tokptr); // Get next octet
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500527 }
528
529 // Data length
530 *data_len = resp_size;
531
532 // Pack the actual response
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700533 std::memcpy(response, &resp_uuid, *data_len);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500534
vishwa1eaea4f2016-02-26 11:57:40 -0600535finish:
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500536 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600537 reply = sd_bus_message_unref(reply);
Sergey Solomineb9b8142016-08-23 09:07:28 -0500538 free(busname);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500539
540 return rc;
541}
Chris Austen6caf28b2015-10-13 12:40:40 -0500542
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500543ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700544 ipmi_request_t request,
545 ipmi_response_t response,
546 ipmi_data_len_t data_len,
547 ipmi_context_t context)
vishwabmcba0bd5f2015-09-30 16:50:23 +0530548{
vishwabmcba0bd5f2015-09-30 16:50:23 +0530549
550 // Status code.
551 ipmi_ret_t rc = IPMI_CC_OK;
552
Adriana Kobylak88ad8152016-12-13 10:09:08 -0600553 // Per IPMI 2.0 spec, the input and output buffer size must be the max
554 // buffer size minus one byte to allocate space for the length byte.
Patrick Venture0b02be92018-08-31 11:55:55 -0700555 uint8_t str[] = {0x01, MAX_IPMI_BUFFER - 1, MAX_IPMI_BUFFER - 1, 0x0A,
556 0x01};
vishwabmcba0bd5f2015-09-30 16:50:23 +0530557
558 // Data length
559 *data_len = sizeof(str);
560
561 // Pack the actual response
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700562 std::memcpy(response, &str, *data_len);
vishwabmcba0bd5f2015-09-30 16:50:23 +0530563
564 return rc;
565}
566
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500567ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700568 ipmi_request_t request,
569 ipmi_response_t response,
570 ipmi_data_len_t data_len,
571 ipmi_context_t context)
vishwabmcba0bd5f2015-09-30 16:50:23 +0530572{
vishwabmcba0bd5f2015-09-30 16:50:23 +0530573 // Status code.
Nan Li70aa8d92016-08-29 00:11:10 +0800574 ipmi_ret_t rc = IPMI_CC_INVALID;
vishwabmcba0bd5f2015-09-30 16:50:23 +0530575
576 *data_len = strlen("THIS IS WILDCARD");
577
578 // Now pack actual response
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700579 std::memcpy(response, "THIS IS WILDCARD", *data_len);
vishwabmcba0bd5f2015-09-30 16:50:23 +0530580
581 return rc;
582}
583
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600584ipmi_ret_t ipmi_app_get_sys_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture0b02be92018-08-31 11:55:55 -0700585 ipmi_request_t request,
586 ipmi_response_t response,
587 ipmi_data_len_t data_len,
588 ipmi_context_t context)
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600589
590{
591 ipmi_ret_t rc = IPMI_CC_OK;
592 sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
593
594 try
595 {
596 // Get the Inventory object implementing BMC interface
597 ipmi::DbusObjectInfo bmcObject =
598 ipmi::getDbusObject(bus, bmc_interface);
599
600 // Read UUID property value from bmcObject
601 // UUID is in RFC4122 format Ex: 61a39523-78f2-11e5-9862-e6402cfc3223
Patrick Venture0b02be92018-08-31 11:55:55 -0700602 auto variant =
603 ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first,
604 bmc_guid_interface, bmc_guid_property);
William A. Kennington III4c008022018-10-12 17:18:14 -0700605 std::string guidProp = variant_ns::get<std::string>(variant);
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600606
607 // Erase "-" characters from the property value
608 guidProp.erase(std::remove(guidProp.begin(), guidProp.end(), '-'),
Patrick Venture0b02be92018-08-31 11:55:55 -0700609 guidProp.end());
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600610
611 auto guidPropLen = guidProp.length();
612 // Validate UUID data
613 // Divide by 2 as 1 byte is built from 2 chars
Patrick Venture0b02be92018-08-31 11:55:55 -0700614 if ((guidPropLen <= 0) || ((guidPropLen / 2) != bmc_guid_len))
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600615
616 {
617 log<level::ERR>("Invalid UUID property value",
Patrick Venture0b02be92018-08-31 11:55:55 -0700618 entry("UUID_LENGTH=%d", guidPropLen));
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600619 return IPMI_CC_RESPONSE_ERROR;
620 }
621
622 // Convert data in RFC4122(MSB) format to LSB format
623 // Get 2 characters at a time as 1 byte is built from 2 chars and
624 // convert to hex byte
625 // TODO: Data printed for GUID command is not as per the
626 // GUID format defined in IPMI specification 2.0 section 20.8
627 // Ticket raised: https://sourceforge.net/p/ipmitool/bugs/501/
628 uint8_t respGuid[bmc_guid_len];
629 for (size_t i = 0, respLoc = (bmc_guid_len - 1);
Patrick Venture0b02be92018-08-31 11:55:55 -0700630 i < guidPropLen && respLoc >= 0; i += 2, respLoc--)
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600631 {
632 auto value = static_cast<uint8_t>(
Patrick Venture0b02be92018-08-31 11:55:55 -0700633 std::stoi(guidProp.substr(i, 2).c_str(), NULL, 16));
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600634 respGuid[respLoc] = value;
635 }
636
637 *data_len = bmc_guid_len;
Patrick Ventureb51bf9c2018-09-10 15:53:14 -0700638 std::memcpy(response, &respGuid, bmc_guid_len);
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600639 }
640 catch (const InternalFailure& e)
641 {
642 log<level::ERR>("Failed in reading BMC UUID property",
643 entry("INTERFACE=%s", bmc_interface),
644 entry("PROPERTY_INTERFACE=%s", bmc_guid_interface),
645 entry("PROPERTY=%s", bmc_guid_property));
646 return IPMI_CC_UNSPECIFIED_ERROR;
647 }
648 return rc;
649}
650
Xo Wangf542e8b2017-08-09 15:34:16 -0700651static std::unique_ptr<SysInfoParamStore> sysInfoParamStore;
652
Xo Wang87651332017-08-11 10:17:59 -0700653static std::string sysInfoReadSystemName()
654{
655 // Use the BMC hostname as the "System Name."
656 char hostname[HOST_NAME_MAX + 1] = {};
657 if (gethostname(hostname, HOST_NAME_MAX) != 0)
658 {
659 perror("System info parameter: system name");
660 }
661 return hostname;
662}
663
Xo Wangf542e8b2017-08-09 15:34:16 -0700664struct IpmiSysInfoResp
665{
666 uint8_t paramRevision;
667 uint8_t setSelector;
668 union
669 {
670 struct
671 {
672 uint8_t encoding;
673 uint8_t stringLen;
674 uint8_t stringData0[14];
675 } __attribute__((packed));
676 uint8_t stringDataN[16];
677 uint8_t byteData;
678 };
679} __attribute__((packed));
680
681/**
682 * Split a string into (up to) 16-byte chunks as expected in response for get
683 * system info parameter.
684 *
685 * @param[in] fullString: Input string to be split
686 * @param[in] chunkIndex: Index of the chunk to be written out
687 * @param[in,out] chunk: Output data buffer; must have 14 byte capacity if
688 * chunk_index = 0 and 16-byte capacity otherwise
689 * @return the number of bytes written into the output buffer, or -EINVAL for
690 * invalid arguments.
691 */
692static int splitStringParam(const std::string& fullString, int chunkIndex,
693 uint8_t* chunk)
694{
695 constexpr int maxChunk = 255;
696 constexpr int smallChunk = 14;
697 constexpr int chunkSize = 16;
698 if (chunkIndex > maxChunk || chunk == nullptr)
699 {
700 return -EINVAL;
701 }
702 try
703 {
704 std::string output;
705 if (chunkIndex == 0)
706 {
707 // Output must have 14 byte capacity.
708 output = fullString.substr(0, smallChunk);
709 }
710 else
711 {
712 // Output must have 16 byte capacity.
713 output = fullString.substr((chunkIndex * chunkSize) - 2, chunkSize);
714 }
715
716 std::memcpy(chunk, output.c_str(), output.length());
717 return output.length();
718 }
719 catch (const std::out_of_range& e)
720 {
721 // The position was beyond the end.
722 return -EINVAL;
723 }
724}
725
726/**
727 * Packs the Get Sys Info Request Item into the response.
728 *
729 * @param[in] paramString - the parameter.
730 * @param[in] setSelector - the selector
731 * @param[in,out] resp - the System info response.
732 * @return The number of bytes packed or failure from splitStringParam().
733 */
734static int packGetSysInfoResp(const std::string& paramString,
735 uint8_t setSelector, IpmiSysInfoResp* resp)
736{
737 uint8_t* dataBuffer = resp->stringDataN;
738 resp->setSelector = setSelector;
739 if (resp->setSelector == 0) // First chunk has only 14 bytes.
740 {
741 resp->encoding = 0;
742 resp->stringLen = paramString.length();
743 dataBuffer = resp->stringData0;
744 }
745 return splitStringParam(paramString, resp->setSelector, dataBuffer);
746}
747
748ipmi_ret_t ipmi_app_get_system_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
749 ipmi_request_t request,
750 ipmi_response_t response,
751 ipmi_data_len_t dataLen,
752 ipmi_context_t context)
753{
754 IpmiSysInfoResp resp = {};
755 size_t respLen = 0;
756 uint8_t* const reqData = static_cast<uint8_t*>(request);
757 std::string paramString;
758 bool found;
759 std::tuple<bool, std::string> ret;
760 constexpr int minRequestSize = 4;
761 constexpr int paramSelector = 1;
762 constexpr uint8_t revisionOnly = 0x80;
763 const uint8_t paramRequested = reqData[paramSelector];
764 int rc;
765
766 if (*dataLen < minRequestSize)
767 {
768 return IPMI_CC_REQ_DATA_LEN_INVALID;
769 }
770
771 *dataLen = 0; // default to 0.
772
773 // Parameters revision as of IPMI spec v2.0 rev. 1.1 (Feb 11, 2014 E6)
774 resp.paramRevision = 0x11;
775 if (reqData[0] & revisionOnly) // Get parameter revision only
776 {
777 respLen = 1;
778 goto writeResponse;
779 }
780
781 // The "Set In Progress" parameter can be used for rollback of parameter
782 // data and is not implemented.
783 if (paramRequested == 0)
784 {
785 resp.byteData = 0;
786 respLen = 2;
787 goto writeResponse;
788 }
789
790 if (sysInfoParamStore == nullptr)
791 {
792 sysInfoParamStore = std::make_unique<SysInfoParamStore>();
Xo Wang87651332017-08-11 10:17:59 -0700793 sysInfoParamStore->update(IPMI_SYSINFO_SYSTEM_NAME,
794 sysInfoReadSystemName);
Xo Wangf542e8b2017-08-09 15:34:16 -0700795 }
796
797 // Parameters other than Set In Progress are assumed to be strings.
798 ret = sysInfoParamStore->lookup(paramRequested);
799 found = std::get<0>(ret);
800 paramString = std::get<1>(ret);
801 if (!found)
802 {
803 return IPMI_CC_SYSTEM_INFO_PARAMETER_NOT_SUPPORTED;
804 }
805 // TODO: Cache each parameter across multiple calls, until the whole string
806 // has been read out. Otherwise, it's possible for a parameter to change
807 // between requests for its chunks, returning chunks incoherent with each
808 // other. For now, the parameter store is simply required to have only
809 // idempotent callbacks.
810 rc = packGetSysInfoResp(paramString, reqData[2], &resp);
811 if (rc == -EINVAL)
812 {
813 return IPMI_CC_RESPONSE_ERROR;
814 }
815
816 respLen = sizeof(resp); // Write entire string data chunk in response.
817
818writeResponse:
819 std::memcpy(response, &resp, sizeof(resp));
820 *dataLen = respLen;
821 return IPMI_CC_OK;
822}
823
Chris Austen6caf28b2015-10-13 12:40:40 -0500824void register_netfn_app_functions()
vishwabmcba0bd5f2015-09-30 16:50:23 +0530825{
Tom05732372016-09-06 17:21:23 +0530826 // <Get BT Interface Capabilities>
Patrick Venture0b02be92018-08-31 11:55:55 -0700827 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL,
828 ipmi_app_get_bt_capabilities, PRIVILEGE_USER);
Chris Austen6caf28b2015-10-13 12:40:40 -0500829
Tom05732372016-09-06 17:21:23 +0530830 // <Wildcard Command>
Patrick Venture0b02be92018-08-31 11:55:55 -0700831 ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL,
832 ipmi_app_wildcard_handler, PRIVILEGE_USER);
Chris Austen6caf28b2015-10-13 12:40:40 -0500833
Tom05732372016-09-06 17:21:23 +0530834 // <Reset Watchdog Timer>
Patrick Venture0b02be92018-08-31 11:55:55 -0700835 ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL,
836 ipmi_app_watchdog_reset, PRIVILEGE_OPERATOR);
Chris Austen6caf28b2015-10-13 12:40:40 -0500837
Tom05732372016-09-06 17:21:23 +0530838 // <Set Watchdog Timer>
Patrick Venture0b02be92018-08-31 11:55:55 -0700839 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL,
840 ipmi_app_watchdog_set, PRIVILEGE_OPERATOR);
Chris Austen6caf28b2015-10-13 12:40:40 -0500841
William A. Kennington III73f44512018-02-09 15:28:46 -0800842 // <Get Watchdog Timer>
Patrick Venture0b02be92018-08-31 11:55:55 -0700843 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_WD, NULL,
844 ipmi_app_watchdog_get, PRIVILEGE_OPERATOR);
William A. Kennington III73f44512018-02-09 15:28:46 -0800845
Tom05732372016-09-06 17:21:23 +0530846 // <Get Device ID>
Patrick Venture0b02be92018-08-31 11:55:55 -0700847 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL,
848 ipmi_app_get_device_id, PRIVILEGE_USER);
Chris Austen6caf28b2015-10-13 12:40:40 -0500849
Tom05732372016-09-06 17:21:23 +0530850 // <Get Self Test Results>
Patrick Venture0b02be92018-08-31 11:55:55 -0700851 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SELF_TEST_RESULTS, NULL,
852 ipmi_app_get_self_test_results, PRIVILEGE_USER);
Nan Li41fa24a2016-11-10 20:12:37 +0800853
Tom05732372016-09-06 17:21:23 +0530854 // <Get Device GUID>
Patrick Venture0b02be92018-08-31 11:55:55 -0700855 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL,
856 ipmi_app_get_device_guid, PRIVILEGE_USER);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500857
Tom05732372016-09-06 17:21:23 +0530858 // <Set ACPI Power State>
Patrick Venture0b02be92018-08-31 11:55:55 -0700859 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL,
860 ipmi_app_set_acpi_power_state, PRIVILEGE_ADMIN);
Chris Austen6caf28b2015-10-13 12:40:40 -0500861
Tom Joseph69fabfe2017-08-04 10:15:01 +0530862 // <Get Channel Access>
Patrick Venture0b02be92018-08-31 11:55:55 -0700863 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHANNEL_ACCESS, NULL,
864 ipmi_get_channel_access, PRIVILEGE_USER);
Tom Joseph69fabfe2017-08-04 10:15:01 +0530865
Tom05732372016-09-06 17:21:23 +0530866 // <Get Channel Info Command>
Patrick Venture0b02be92018-08-31 11:55:55 -0700867 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL,
868 ipmi_app_channel_info, PRIVILEGE_USER);
Chris Austenc2cd29d2016-02-05 20:02:29 -0600869
Marri Devender Rao5e007a52018-01-08 06:18:36 -0600870 // <Get System GUID Command>
Patrick Venture0b02be92018-08-31 11:55:55 -0700871 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SYS_GUID, NULL,
872 ipmi_app_get_sys_guid, PRIVILEGE_USER);
Tom Joseph7cbe2282018-03-21 21:17:33 +0530873
874 // <Get Channel Cipher Suites Command>
Patrick Venture0b02be92018-08-31 11:55:55 -0700875 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_CIPHER_SUITES, NULL,
876 getChannelCipherSuites, PRIVILEGE_CALLBACK);
Tom Joseph13227682018-08-10 01:05:21 +0530877
878 // <Set Channel Access Command>
879 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_CHAN_ACCESS, NULL,
880 ipmi_set_channel_access, PRIVILEGE_ADMIN);
Xo Wangf542e8b2017-08-09 15:34:16 -0700881
882 // <Get System Info Command>
883 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SYSTEM_INFO, NULL,
884 ipmi_app_get_system_info, PRIVILEGE_USER);
vishwabmcba0bd5f2015-09-30 16:50:23 +0530885 return;
886}