16 #ifndef PSEN_SCAN_V2_STANDALONE_UTIL_IP_CONVERSION_H 17 #define PSEN_SCAN_V2_STANDALONE_UTIL_IP_CONVERSION_H 26 #include <arpa/inet.h> 37 inline uint32_t convertIP(
const std::string& ip)
39 const auto ip_number = inet_network(ip.c_str());
40 if (static_cast<in_addr_t>(-1) == ip_number)
42 throw std::invalid_argument(
"IP invalid");
44 assert(
sizeof(ip_number) == 4 &&
"ip_number has not the expected size");
45 return static_cast<uint32_t
>(ip_number);
50 inline uint32_t convertIP(
const std::string& ip)
52 const auto ip_number = inet_addr(ip.c_str());
53 if (INADDR_NONE == ip_number)
55 throw std::invalid_argument(
"IP invalid");
57 assert(
sizeof(ip_number) == 4 &&
"ip_number has not the expected size");
58 return htonl(static_cast<uint32_t>(ip_number));
64 if (port < std::numeric_limits<uint16_t>::min() || port > std::numeric_limits<uint16_t>::max())
66 throw std::out_of_range(
"Port out of range");
68 return static_cast<uint16_t
>(port);
uint16_t convertPort(const int &port)
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...