blob: 735ee1524ad91f6a47b9f8025f57a7be3cfc2fe1 [file] [log] [blame]
#pragma once
#include <cstdint>
#include <string>
#include <tuple>
namespace google
{
namespace ipmi
{
using VersionTuple =
std::tuple<std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
class HandlerInterface
{
public:
virtual ~HandlerInterface() = default;
/**
* Return ethernet details (hard-coded).
*
* @return tuple of ethernet details (channel, if name).
*/
virtual std::tuple<std::uint8_t, std::string> getEthDetails() const = 0;
/**
* Return the value of rx_packets, given a if_name.
*
* @param[in] name, the interface name.
* @return the number of packets received.
* @throw IpmiException on failure.
*/
virtual std::int64_t getRxPackets(const std::string& name) const = 0;
/**
* Return the values from a cpld version file.
*
* @param[in] id - the cpld id number.
* @return the quad of numbers as a tuple (maj,min,pt,subpt)
* @throw IpmiException on failure.
*/
virtual VersionTuple getCpldVersion(unsigned int id) const = 0;
};
class Handler : public HandlerInterface
{
public:
Handler() = default;
~Handler() = default;
std::tuple<std::uint8_t, std::string> getEthDetails() const override;
std::int64_t getRxPackets(const std::string& name) const override;
VersionTuple getCpldVersion(unsigned int id) const override;
};
extern Handler handlerImpl;
} // namespace ipmi
} // namespace google