1#ifndef IV_SRC_COMMS_IP_FUNCTIONS_HPP_
2#define IV_SRC_COMMS_IP_FUNCTIONS_HPP_
12bool isAllowedIP(
const std::string &sourceIp,
const std::set<std::string> &allowedIPs)
14 static const std::vector<std::string> exceptions {
"127.0.0.255",
"127.0.0.1",
"localhost",
"::1",
"0.0.0.0"};
15 static const auto findIp = [sourceIp](
const std::string &ip) {
return ip == sourceIp; };
16 return std::ranges::any_of(exceptions, findIp) || std::ranges::any_of(allowedIPs, findIp);
22 char *chrEnv = getenv(
"SHOW_LAN_MESSAGE");
24 if (chrEnv !=
nullptr && strcmp(chrEnv,
"1") == 0)
26 printf(
">>>>> LAN >>>>> Time: %10u, ID: %08X, ", timestamp, msgId);
29 for (int32_t bIndex = 0; bIndex < 8; bIndex++)
31 printf(
"%02X ", bytes[bIndex]);
bool isAllowedIP(const std::string &sourceIp, const std::set< std::string > &allowedIPs)
Definition functions.hpp:12
void showLANMessage(uint32_t timestamp, uint32_t msgId, const uint8_t *bytes)
Definition functions.hpp:19