Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <string> |
| 5 | #include <tuple> |
| 6 | |
| 7 | namespace google |
| 8 | { |
| 9 | namespace ipmi |
| 10 | { |
| 11 | |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 12 | using VersionTuple = |
| 13 | std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>; |
| 14 | |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 15 | class HandlerInterface |
| 16 | { |
| 17 | public: |
| 18 | virtual ~HandlerInterface() = default; |
| 19 | |
| 20 | /** |
| 21 | * Return ethernet details (hard-coded). |
| 22 | * |
| 23 | * @return tuple of ethernet details (channel, if name). |
| 24 | */ |
| 25 | virtual std::tuple<std::uint8_t, std::string> getEthDetails() const = 0; |
Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Return the value of rx_packets, given a if_name. |
| 29 | * |
| 30 | * @param[in] name, the interface name. |
| 31 | * @return the number of packets received. |
| 32 | * @throw IpmiException on failure. |
| 33 | */ |
| 34 | virtual std::int64_t getRxPackets(const std::string& name) const = 0; |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Return the values from a cpld version file. |
| 38 | * |
| 39 | * @param[in] id - the cpld id number. |
| 40 | * @return the quad of numbers as a tuple (maj,min,pt,subpt) |
| 41 | * @throw IpmiException on failure. |
| 42 | */ |
| 43 | virtual VersionTuple getCpldVersion(unsigned int id) const = 0; |
Patrick Venture | aa37412 | 2019-03-15 15:09:10 -0700 | [diff] [blame^] | 44 | |
| 45 | /** |
| 46 | * Set the PSU Reset delay. |
| 47 | * |
| 48 | * @param[in] delay - delay in seconds. |
| 49 | * @throw IpmiException on failure. |
| 50 | */ |
| 51 | virtual void psuResetDelay(std::uint32_t delay) const = 0; |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | class Handler : public HandlerInterface |
| 55 | { |
| 56 | public: |
| 57 | Handler() = default; |
| 58 | ~Handler() = default; |
| 59 | |
| 60 | std::tuple<std::uint8_t, std::string> getEthDetails() const override; |
Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 61 | std::int64_t getRxPackets(const std::string& name) const override; |
Patrick Venture | bb90d4f | 2019-03-15 13:42:06 -0700 | [diff] [blame] | 62 | VersionTuple getCpldVersion(unsigned int id) const override; |
Patrick Venture | aa37412 | 2019-03-15 15:09:10 -0700 | [diff] [blame^] | 63 | void psuResetDelay(std::uint32_t delay) const override; |
Patrick Venture | f085d91 | 2019-03-15 08:50:00 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | extern Handler handlerImpl; |
| 67 | |
| 68 | } // namespace ipmi |
| 69 | } // namespace google |