blob: 0a0943ff9188f9b36dc878c6659d5c8bc9e88268 (
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
|
#pragma once
#include "data_handler.hpp"
#include <unistd.h>
#include <cstdint>
#include <optional>
#include <stdplus/handle/managed.hpp>
#include <vector>
namespace ipmi_flash
{
/**
* Data Handler for receiving the image over a network port
*/
class NetDataHandler : public DataInterface
{
public:
NetDataHandler() : listenFd(std::nullopt), connFd(std::nullopt)
{
}
bool open() override;
bool close() override;
std::vector<std::uint8_t> copyFrom(std::uint32_t length) override;
bool writeMeta(const std::vector<std::uint8_t>& configuration) override;
std::vector<std::uint8_t> readMeta() override;
static constexpr std::uint16_t listenPort = 623;
static constexpr int timeoutS = 5;
private:
static void closefd(int&& fd)
{
::close(fd);
}
using Fd = stdplus::Managed<int>::Handle<closefd>;
Fd listenFd;
Fd connFd;
};
} // namespace ipmi_flash
|