| #pragma once |
| |
| #include "data_handler.hpp" |
| |
| #include <unistd.h> |
| |
| #include <stdplus/handle/managed.hpp> |
| |
| #include <cstdint> |
| #include <optional> |
| #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 |