blob: 7ed49c8e581da055e573842a3aa8e21df5db6b81 [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
James Feist2a265d52019-04-08 11:16:27 -070019#include <ipmid/api.hpp>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070020#include <sdbusplus/bus.hpp>
James Feistfcd2d3a2020-05-28 10:38:15 -070021
22#include <iostream>
23#include <map>
Patrick Venture7ecaf522019-10-18 19:27:20 -070024#include <string>
Patrick Ventureccfeb042019-10-18 19:43:11 -070025#include <tuple>
Patrick Venture7ecaf522019-10-18 19:27:20 -070026#include <utility>
27#include <vector>
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070028
29static constexpr bool debug = false;
30
31inline static void printRegistration(unsigned int netfn, unsigned int cmd)
32{
33 if constexpr (debug)
34 {
35 std::cout << "Registering NetFn:[0x" << std::hex << std::uppercase
36 << netfn << "], Cmd:[0x" << cmd << "]\n";
37 }
38}
39
40inline static void ipmiPrintAndRegister(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
41 ipmi_context_t context,
42 ipmid_callback_t handler,
43 ipmi_cmd_privilege_t priv)
44{
45 printRegistration(netfn, cmd);
46 ipmi_register_callback(netfn, cmd, context, handler, priv);
47}
48
49inline static void printCommand(unsigned int netfn, unsigned int cmd)
50{
51 if constexpr (debug)
52 {
53 std::cout << "Executing NetFn:[0x" << std::hex << std::uppercase
54 << netfn << "], Cmd:[0x" << cmd << "]\n";
55 }
56}