blob: 30ed68a0284b856c65f8a91af85bbbff7705bac6 [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
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
18#include <iostream>
19#include <sdbusplus/bus.hpp>
20
21static constexpr bool debug = false;
22
23inline static void printRegistration(unsigned int netfn, unsigned int cmd)
24{
25 if constexpr (debug)
26 {
27 std::cout << "Registering NetFn:[0x" << std::hex << std::uppercase
28 << netfn << "], Cmd:[0x" << cmd << "]\n";
29 }
30}
31
32inline static void ipmiPrintAndRegister(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
33 ipmi_context_t context,
34 ipmid_callback_t handler,
35 ipmi_cmd_privilege_t priv)
36{
37 printRegistration(netfn, cmd);
38 ipmi_register_callback(netfn, cmd, context, handler, priv);
39}
40
41inline static void printCommand(unsigned int netfn, unsigned int cmd)
42{
43 if constexpr (debug)
44 {
45 std::cout << "Executing NetFn:[0x" << std::hex << std::uppercase
46 << netfn << "], Cmd:[0x" << cmd << "]\n";
47 }
48}
49
50namespace ipmi
51{
52using DbusVariant =
53 sdbusplus::message::variant<std::string, bool, uint8_t, uint16_t, int16_t,
54 uint32_t, int32_t, uint64_t, int64_t, double>;
James Feistfaa4f222019-03-21 16:21:55 -070055using GetSubTreeType = std::vector<
56 std::pair<std::string,
57 std::vector<std::pair<std::string, std::vector<std::string>>>>>;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070058} // namespace ipmi