Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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 |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 18 | #include <sdbusplus/bus.hpp> |
| 19 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 20 | #include <iostream> |
| 21 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 22 | static constexpr bool debug = false; |
| 23 | |
| 24 | inline static void printRegistration(unsigned int netfn, unsigned int cmd) |
| 25 | { |
| 26 | if constexpr (debug) |
| 27 | { |
| 28 | std::cout << "Registering NetFn:[0x" << std::hex << std::uppercase |
| 29 | << netfn << "], Cmd:[0x" << cmd << "]\n"; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | inline static void ipmiPrintAndRegister(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 34 | ipmi_context_t context, |
| 35 | ipmid_callback_t handler, |
| 36 | ipmi_cmd_privilege_t priv) |
| 37 | { |
| 38 | printRegistration(netfn, cmd); |
| 39 | ipmi_register_callback(netfn, cmd, context, handler, priv); |
| 40 | } |
| 41 | |
| 42 | inline static void printCommand(unsigned int netfn, unsigned int cmd) |
| 43 | { |
| 44 | if constexpr (debug) |
| 45 | { |
| 46 | std::cout << "Executing NetFn:[0x" << std::hex << std::uppercase |
| 47 | << netfn << "], Cmd:[0x" << cmd << "]\n"; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | namespace ipmi |
| 52 | { |
Patrick Williams | bec18ea | 2020-05-13 17:43:23 -0500 | [diff] [blame] | 53 | using DbusVariant = std::variant<std::string, bool, uint8_t, uint16_t, int16_t, |
| 54 | uint32_t, int32_t, uint64_t, int64_t, double>; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 55 | } // namespace ipmi |