blob: 735ee1524ad91f6a47b9f8025f57a7be3cfc2fe1 [file] [log] [blame]
Patrick Venturef085d912019-03-15 08:50:00 -07001#pragma once
2
3#include <cstdint>
4#include <string>
5#include <tuple>
6
7namespace google
8{
9namespace ipmi
10{
11
Patrick Venturebb90d4f2019-03-15 13:42:06 -070012using VersionTuple =
13 std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
14
Patrick Venturef085d912019-03-15 08:50:00 -070015class 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 Ventured2037c62019-03-15 10:29:47 -070026
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 Venturebb90d4f2019-03-15 13:42:06 -070035
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 Venturef085d912019-03-15 08:50:00 -070044};
45
46class Handler : public HandlerInterface
47{
48 public:
49 Handler() = default;
50 ~Handler() = default;
51
52 std::tuple<std::uint8_t, std::string> getEthDetails() const override;
Patrick Ventured2037c62019-03-15 10:29:47 -070053 std::int64_t getRxPackets(const std::string& name) const override;
Patrick Venturebb90d4f2019-03-15 13:42:06 -070054 VersionTuple getCpldVersion(unsigned int id) const override;
Patrick Venturef085d912019-03-15 08:50:00 -070055};
56
57extern Handler handlerImpl;
58
59} // namespace ipmi
60} // namespace google