20 #define IPV4_NUM_OF_BYTES 4U 28 std::stringstream ip_stream(ip_string);
32 if (ip_stream.rdbuf()->in_avail() == 0) {
35 ip_stream >> ip_uint[0];
37 if (ip_stream.fail()) {
43 if (ip_stream.rdbuf()->in_avail() == 0) {
48 if (ip_stream.fail()) {
57 if (ip_stream.rdbuf()->in_avail() == 0) {
60 ip_stream >> ip_uint[i];
62 if (ip_stream.fail()) {
68 if (ip_stream.rdbuf()->in_avail() != 0) {
95 if (ip_uint[i] > 0xFF) {
99 if (min_ip_uint[i] > 0xFF) {
103 if (max_ip_uint[i] > 0xFF) {
110 uint32_t max_num = 0;
111 uint32_t min_num = 0;
114 ip_num = ip_num << 8;
115 ip_num += ip_uint[i];
116 min_num = min_num << 8;
117 min_num += min_ip_uint[i];
118 max_num = max_num << 8;
119 max_num += max_ip_uint[i];
122 if ((ip_num < min_num) || (ip_num > max_num)) {
132 return "The IP string is wrong formatted.";
136 return "The numbers on the ip are not representable by 8 bits.";
140 return "The IP is not in the specified range. Hover over the parameterto see the range.";
bool ipv4_string_to_uint(std::string ip_string, uint *ip_uint)
Converts a IPv4 in a string to a array of unsigned integers, where the most significant byte of the I...
IPValidation
Type used to validate a IP string.
std::string get_error_msg(IPValidation error)
Get the error msg based on the validation type.
IPValidation check_valid_ip(std::string ip, std::string min_ip, std::string max_ip)
Checks if a IP is valid and is in the specified range.