Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 1 | #include "types.hpp" |
| 2 | #include "host-ipmid/ipmid-api.h" |
| 3 | |
| 4 | namespace ipmi |
| 5 | { |
| 6 | namespace sensor |
| 7 | { |
| 8 | |
| 9 | using Assertion = uint16_t; |
| 10 | using Deassertion = uint16_t; |
| 11 | using AssertionSet = std::pair<Assertion, Deassertion>; |
| 12 | |
| 13 | using Service = std::string; |
| 14 | using Path = std::string; |
| 15 | using Interface = std::string; |
| 16 | |
| 17 | using ServicePath = std::pair<Path, Service>; |
| 18 | |
| 19 | using Interfaces = std::vector<Interface>; |
| 20 | |
| 21 | using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>; |
| 22 | |
| 23 | /** @brief get the D-Bus service and service path |
| 24 | * @param[in] bus - The Dbus bus object |
| 25 | * @param[in] interface - interface to the service |
| 26 | * @param[in] path - interested path in the list of objects |
| 27 | * @return pair of service path and service |
| 28 | */ |
| 29 | ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, |
| 30 | const std::string& interface, |
| 31 | const std::string& path = std::string()); |
| 32 | |
| 33 | /** @brief Make assertion set from input data |
| 34 | * @param[in] cmdData - Input sensor data |
| 35 | * @return pair of assertion and deassertion set |
| 36 | */ |
| 37 | AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData); |
| 38 | |
| 39 | /** @brief send the message to DBus |
| 40 | * @param[in] msg - message to send |
| 41 | * @return failure status in IPMI error code |
| 42 | */ |
Dhruvaraj Subhashchandran | 2a444d0 | 2017-08-07 01:45:14 -0500 | [diff] [blame] | 43 | ipmi_ret_t updateToDbus(IpmiUpdateData& msg); |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 44 | |
| 45 | namespace set |
| 46 | { |
| 47 | |
| 48 | /** @brief Make a DBus message for a Dbus call |
| 49 | * @param[in] updateInterface - Interface name |
| 50 | * @param[in] sensorPath - Path of the sensor |
| 51 | * @param[in] command - command to be executed |
| 52 | * @param[in] sensorInterface - DBus interface of sensor |
| 53 | * @return a dbus message |
| 54 | */ |
| 55 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 56 | const std::string& sensorPath, |
| 57 | const std::string& command, |
| 58 | const std::string& sensorInterface); |
| 59 | |
| 60 | /** @brief Create a message for IPMI assertion |
| 61 | * @param[in] msg - Message to add the values |
| 62 | * @param[in] interface - sensor interface |
| 63 | * @param[in] sensorPath - Path of the sensor |
| 64 | * @param[in] cmdData - input sensor data |
| 65 | * @return a IPMI error code |
| 66 | */ |
| 67 | ipmi_ret_t appendAssertion(IpmiUpdateData& msg, |
| 68 | const DbusInterfaceMap& interfaceMap, |
| 69 | const std::string& sensorPath, |
| 70 | const SetSensorReadingReq& cmdData); |
| 71 | |
| 72 | /** @brief Create a message for discrete signal |
| 73 | * @param[in] msg - Message to add the values |
| 74 | * @param[in] interface - sensor interface |
| 75 | * @param[in] data - input discrete sensor data |
| 76 | * @return a IPMI error code |
| 77 | */ |
| 78 | ipmi_ret_t appendDiscreteSignalData(IpmiUpdateData& msg, |
| 79 | const DbusInterfaceMap& interfaceMap, |
| 80 | uint8_t data); |
| 81 | |
| 82 | /** @brief Create a message for reading data |
| 83 | * @param[in] msg - Message to add the values |
| 84 | * @param[in] interface - sensor interface |
| 85 | * @param[in] data - input sensor data |
| 86 | * @return a IPMI error code |
| 87 | */ |
| 88 | ipmi_ret_t appendReadingData(IpmiUpdateData& msg, |
| 89 | const DbusInterfaceMap& interfaceMap, |
| 90 | const Value& data); |
| 91 | |
| 92 | }//namespace set |
| 93 | |
| 94 | namespace notify |
| 95 | { |
| 96 | |
| 97 | /** @brief Make a DBus message for a Dbus call |
| 98 | * @param[in] updateInterface - Interface name |
| 99 | * @param[in] sensorPath - Path of the sensor |
| 100 | * @param[in] command - command to be executed |
| 101 | * @param[in] sensorInterface - DBus interface of sensor |
| 102 | * @return a dbus message |
| 103 | */ |
| 104 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 105 | const std::string& sensorPath, |
| 106 | const std::string& command, |
| 107 | const std::string& sensorInterface); |
| 108 | |
| 109 | /** @brief Create a message for IPMI discrete signal |
| 110 | * @param[in] msg - Message to add the values |
| 111 | * @param[in] interfaceMap - sensor interface |
| 112 | * @param[in] sensorPath - Path of the sensor |
| 113 | * @param[in] cmdData - input sensor data |
| 114 | * @return a IPMI error code |
| 115 | */ |
| 116 | inline ipmi_ret_t appendDiscreteSignalData(IpmiUpdateData& msg, |
| 117 | const DbusInterfaceMap& interfaceMap, |
| 118 | uint8_t data) |
| 119 | { |
| 120 | return IPMI_CC_OK; |
| 121 | } |
| 122 | |
| 123 | /** @brief Create a message for reading data |
| 124 | * @param[in] msg - Message to add the values |
| 125 | * @param[in] interfaceMap - sensor interface |
| 126 | * @param[in] data - input sensor data |
| 127 | * @return a IPMI error code |
| 128 | */ |
| 129 | inline ipmi_ret_t appendReadingData(IpmiUpdateData& msg, |
| 130 | const DbusInterfaceMap& interfaceMap, |
| 131 | const Value &data) |
| 132 | { |
| 133 | return IPMI_CC_OK; |
| 134 | } |
| 135 | |
| 136 | /** @brief Create a message for IPMI asserting |
| 137 | * @param[in] msg - Message to add the values |
| 138 | * @param[in] interfaceMap - sensor interface |
| 139 | * @param[in] sensorPath - Path of the sensor |
| 140 | * @param[in] cmdData - input sensor data |
| 141 | * @return a IPMI error code |
| 142 | */ |
| 143 | ipmi_ret_t appendAssertion(IpmiUpdateData& msg, |
| 144 | const DbusInterfaceMap& interfaceMap, |
| 145 | const std::string& sensorPath, |
| 146 | const SetSensorReadingReq& cmdData); |
| 147 | |
| 148 | }//namespace notify |
| 149 | }//namespace sensor |
| 150 | }//namespace ipmi |