49 WOL::WOL(uint64_t hardware_addr, uint16_t port) noexcept :
50 hardware_addr_(toByteArray<6>(std::move(hardware_addr))),
54 WOL::WOL(std::array<uint8_t, 6> hardware_addr, uint16_t port) noexcept :
55 hardware_addr_(std::move(hardware_addr)),
64 void WOL::send(
const std::array<uint8_t, 4>& password)
const 70 std::vector<uint8_t>& sendbuf,
71 const std::array<uint8_t, 4> *password)
const 73 for (
int i = 0; i < 6; ++i)
75 sendbuf.push_back(0xFF);
77 for (
int i = 0; i < 16; ++i)
84 if (password !=
nullptr)
86 for (
int i = 0; i < 4; ++i)
88 sendbuf.push_back((*password)[i]);
98 std::array<uint8_t, num> result;
99 for (uint8_t i = 0; i < num; ++i)
101 result[i] =
static_cast<uint8_t
>((data >> (((num - 1 - i)*8))) & 0xFF);
110 for (
auto &socket : sockets)
112 std::vector<uint8_t> sendbuf;
115 socket.enableBroadcast();
116 socket.enableNonBlocking();
120 socket.send(sendbuf);
static std::vector< SocketLinux > createAndBindForAllInterfaces(uint16_t port)
Creates sockets for all interfaces and binds them to the respective interface.
Exception representing a Network Unreachable error (code 101 on Unix).
std::vector< uint8_t > & appendMagicPacket(std::vector< uint8_t > &sendbuf, const std::array< uint8_t, 4 > *password) const
Appends a magic packet to a data buffer.
WOL(uint64_t hardware_addr, uint16_t port) noexcept
Constructor.
std::array< uint8_t, num > toByteArray(uint64_t data) noexcept
Converts a larger-than-byte data type to an array of bytes.
void sendImpl(const std::array< uint8_t, 4 > *password) const
sendImpl Actually send Magic packet with specified data.
const std::array< uint8_t, 6 > hardware_addr_
void send() const
Send Magic Packet without any data ("password").