Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2017 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
Patrick Venture | 7ecaf52 | 2019-10-18 19:27:20 -0700 | [diff] [blame] | 18 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 19 | #include <iostream> |
James Feist | 2a265d5 | 2019-04-08 11:16:27 -0700 | [diff] [blame] | 20 | #include <ipmid/api.hpp> |
Patrick Venture | 262276f | 2019-10-18 13:27:59 -0700 | [diff] [blame] | 21 | #include <map> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 22 | #include <sdbusplus/bus.hpp> |
Patrick Venture | 7ecaf52 | 2019-10-18 19:27:20 -0700 | [diff] [blame] | 23 | #include <string> |
Patrick Venture | ccfeb04 | 2019-10-18 19:43:11 -0700 | [diff] [blame] | 24 | #include <tuple> |
Patrick Venture | 7ecaf52 | 2019-10-18 19:27:20 -0700 | [diff] [blame] | 25 | #include <utility> |
| 26 | #include <vector> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 27 | |
| 28 | static constexpr bool debug = false; |
| 29 | |
| 30 | inline static void printRegistration(unsigned int netfn, unsigned int cmd) |
| 31 | { |
| 32 | if constexpr (debug) |
| 33 | { |
| 34 | std::cout << "Registering NetFn:[0x" << std::hex << std::uppercase |
| 35 | << netfn << "], Cmd:[0x" << cmd << "]\n"; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | inline static void ipmiPrintAndRegister(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 40 | ipmi_context_t context, |
| 41 | ipmid_callback_t handler, |
| 42 | ipmi_cmd_privilege_t priv) |
| 43 | { |
| 44 | printRegistration(netfn, cmd); |
| 45 | ipmi_register_callback(netfn, cmd, context, handler, priv); |
| 46 | } |
| 47 | |
| 48 | inline static void printCommand(unsigned int netfn, unsigned int cmd) |
| 49 | { |
| 50 | if constexpr (debug) |
| 51 | { |
| 52 | std::cout << "Executing NetFn:[0x" << std::hex << std::uppercase |
| 53 | << netfn << "], Cmd:[0x" << cmd << "]\n"; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | namespace ipmi |
| 58 | { |
Patrick Venture | ccfeb04 | 2019-10-18 19:43:11 -0700 | [diff] [blame] | 59 | using Association = std::tuple<std::string, std::string, std::string>; |
| 60 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 61 | using DbusVariant = |
| 62 | sdbusplus::message::variant<std::string, bool, uint8_t, uint16_t, int16_t, |
Patrick Venture | ccfeb04 | 2019-10-18 19:43:11 -0700 | [diff] [blame] | 63 | uint32_t, int32_t, uint64_t, int64_t, double, |
| 64 | std::vector<Association>>; |
James Feist | faa4f22 | 2019-03-21 16:21:55 -0700 | [diff] [blame] | 65 | using GetSubTreeType = std::vector< |
| 66 | std::pair<std::string, |
| 67 | std::vector<std::pair<std::string, std::vector<std::string>>>>>; |
Patrick Venture | 262276f | 2019-10-18 13:27:59 -0700 | [diff] [blame] | 68 | |
| 69 | using SensorMap = std::map<std::string, std::map<std::string, DbusVariant>>; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 70 | } // namespace ipmi |