#ifndef USER_IPS_H
#define USER_IPS_H
+#ifdef FREE_BSD
+#include <sys/types.h>
+#endif
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <cstring>
#include <vector>
-//#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>
-#include <cstring>
-/////////////////////////
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include "common.h"
#include "os_int.h"
std::string err;
if (ipsStr.empty())
{
- err = "Incorrect IP address.";
- throw(err);
+ return ips;
}
if (ipsStr[0] == '*' && ipsStr.size() == 1)
if (strIp == NULL)
{
err = "Incorrect IP address " + ipsStr;
- throw(err);
+ return ips;
}
strMask = strtok(NULL, "/");
if (im.ip == INADDR_NONE)
{
err = "Incorrect IP address: " + std::string(strIp);
- throw(err);
+ return ips;
}
im.mask = 32;
if (str2x(strMask, m) != 0)
{
err = "Incorrect mask: " + std::string(strMask);
- throw(err);
+ return ips;
}
im.mask = m;
if (im.mask > 32)
{
err = "Incorrect mask: " + std::string(strMask);
- throw(err);
+ return ips;
}
if ((im.ip & ips.CalcMask(im.mask)) != im.ip)
{
err = "Address does'n match mask: " + std::string(strIp) + "/" + std::string(strMask);
- throw(err);
+ return ips;
}
}
ips.ips.push_back(im);
}
//-------------------------------------------------------------------------
#endif //USER_IPS_H
-
-