blob: 21d0fc797d7977d51d42934ce872baa018e52d35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include "internal/sys.hpp"
#include "ipmi_interface.hpp"
#include <memory>
#include <vector>
namespace ipmiblob
{
class IpmiHandler : public IpmiInterface
{
public:
/* Create an IpmiHandler object with default inputs. It is ill-advised to
* share IpmiHandlers between objects.
*/
static std::unique_ptr<IpmiInterface> CreateIpmiHandler();
explicit IpmiHandler(const internal::Sys* sys = &internal::sys_impl) :
sys(sys){};
~IpmiHandler() = default;
IpmiHandler(const IpmiHandler&) = delete;
IpmiHandler& operator=(const IpmiHandler&) = delete;
IpmiHandler(IpmiHandler&&) = default;
IpmiHandler& operator=(IpmiHandler&&) = default;
/**
* Attempt to open the device node.
*
* @throws IpmiException on failure.
*/
void open();
/**
* @throws IpmiException on failure.
*/
std::vector<std::uint8_t>
sendPacket(std::uint8_t netfn, std::uint8_t cmd,
std::vector<std::uint8_t>& data) override;
private:
const internal::Sys* sys;
/** TODO: Use a smart file descriptor when it's ready. Until then only
* allow moving this object.
*/
int fd = -1;
/* The last IPMI sequence number we used. */
int sequence = 0;
};
} // namespace ipmiblob
|