blob: cad6e2d0b42103d963fafed75d0b4788c5311038 [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
Patrick Venture7ecaf522019-10-18 19:27:20 -070018
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070019#include <iostream>
James Feist2a265d52019-04-08 11:16:27 -070020#include <ipmid/api.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070021#include <sdbusplus/bus.hpp>
Patrick Venture7ecaf522019-10-18 19:27:20 -070022#include <string>
Patrick Ventureccfeb042019-10-18 19:43:11 -070023#include <tuple>
Patrick Venture7ecaf522019-10-18 19:27:20 -070024#include <utility>
25#include <vector>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070026
27static constexpr bool debug = false;
28
29inline static void printRegistration(unsigned int netfn, unsigned int cmd)
30{
31 if constexpr (debug)
32 {
33 std::cout << "Registering NetFn:[0x" << std::hex << std::uppercase
34 << netfn << "], Cmd:[0x" << cmd << "]\n";
35 }
36}
37
38inline static void ipmiPrintAndRegister(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
39 ipmi_context_t context,
40 ipmid_callback_t handler,
41 ipmi_cmd_privilege_t priv)
42{
43 printRegistration(netfn, cmd);
44 ipmi_register_callback(netfn, cmd, context, handler, priv);
45}
46
47inline static void printCommand(unsigned int netfn, unsigned int cmd)
48{
49 if constexpr (debug)
50 {
51 std::cout << "Executing NetFn:[0x" << std::hex << std::uppercase
52 << netfn << "], Cmd:[0x" << cmd << "]\n";
53 }
54}
55
56namespace ipmi
57{
Patrick Ventureccfeb042019-10-18 19:43:11 -070058using Association = std::tuple<std::string, std::string, std::string>;
59
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070060using DbusVariant =
61 sdbusplus::message::variant<std::string, bool, uint8_t, uint16_t, int16_t,
Patrick Ventureccfeb042019-10-18 19:43:11 -070062 uint32_t, int32_t, uint64_t, int64_t, double,
63 std::vector<Association>>;
James Feistfaa4f222019-03-21 16:21:55 -070064using GetSubTreeType = std::vector<
65 std::pair<std::string,
66 std::vector<std::pair<std::string, std::vector<std::string>>>>>;
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070067} // namespace ipmi