void IP_RANGE::load(const std::string& ip)
{
string::size_type delim_pos;
- struct in_addr ia_ip1, ia_ip2;
-
+
if ((delim_pos=ip.find('/')) != string::npos ||
(delim_pos=ip.find('-')) != string::npos)
{
if (delim_pos+1 >= ip.size())
throw runtime_error("invalid IP given: "+ip);
-
+
if (ip.at(delim_pos) == '/')
t=NETWORK;
else
t=RANGE;
-
+
load(t,ip.substr(0,delim_pos),ip.substr(delim_pos+1));
}
else
{
- load(IP,ip,"");
+ load(IP,ip,"");
}
}
void IP_RANGE::load(type t, unsigned int ip, unsigned int mask_or_end)
{
- struct in_addr ia_ip1, ia_ip2;
-
this->t=t;
-
+
if (t==IP)
{
this->ip=ip;
{
this->ip=ip;
this->mask=mask_or_end;
-
+
// make sure ip is really the network address
this->ip=(this->ip & this->mask);
-
+
// calculate end of the network (=broadcast addr)
this->end=((this->mask ^ 0xFFFFFFFF) | this->ip);
}
{
this->ip=ip;
this->end=mask_or_end;
-
+
// Automatically turn IP if IP & end are swapped
if (turn_ip(this->ip) > turn_ip(this->end)) {
unsigned int tmp = this->ip;