#include <iostream>
#include <sstream>
-#include "common.h"
+#include "stg/common.h"
#include "os_int.h"
using namespace std;
}
//-----------------------------------------------------------------------------
inline
+uint32_t USER_IPS::CalcMask(unsigned int msk) const
+{
+if (msk > 32)
+ return 0;
+return htonl(0xFFffFFff << (32 - msk));
+}
+//-----------------------------------------------------------------------------
+inline
bool USER_IPS::IsIPInIPS(uint32_t ip) const
{
if (ips.empty())
}
//-----------------------------------------------------------------------------
inline
-uint32_t USER_IPS::CalcMask(unsigned int msk) const
-{
-if (msk > 32)
- return 0;
-return htonl(0xFFffFFff << (32 - msk));
-}
-//-----------------------------------------------------------------------------
-inline
void USER_IPS::Add(const IP_MASK &im)
{
ips.push_back(im);
char * paddr;
IP_MASK im;
std::vector<std::string> ipMask;
-std::string err;
if (ipsStr.empty())
{
return ips;
strIp = strtok(str, "/");
if (strIp == NULL)
{
- err = "Incorrect IP address " + ipsStr;
return ips;
}
strMask = strtok(NULL, "/");
im.ip = inet_addr(strIp);
if (im.ip == INADDR_NONE)
{
- err = "Incorrect IP address: " + std::string(strIp);
return ips;
}
int m = 0;
if (str2x(strMask, m) != 0)
{
- err = "Incorrect mask: " + std::string(strMask);
return ips;
}
im.mask = m;
if (im.mask > 32)
{
- err = "Incorrect mask: " + std::string(strMask);
return ips;
}
if ((im.ip & ips.CalcMask(im.mask)) != im.ip)
{
- err = "Address does'n match mask: " + std::string(strIp) + "/" + std::string(strMask);
return ips;
}
}