((a.ip==b.ip) && IP_RANGE::turn_ip(a.end) < IP_RANGE::turn_ip(b.end)));
}
-std::string IP_RANGE::to_string(void) const
+std::string IP_RANGE::to_string(bool always_mask) const
{
struct in_addr ia_ip;
static const int bufsize=16;
output=output+"-"+buffer;
}
- return output;
+ // t == IP
+ if (always_mask)
+ return output+"/32";
+ else
+ return output;
}
vector<IP_RANGE> IP_RANGE::to_cidr(void) const
return cidrs;
}
-#include <iostream>
-
vector<IP_RANGE> IP_RANGE::substract(const std::set<IP_RANGE> &to_substract) const
{
vector<IP_RANGE> rtn;
int operator-(const IP_RANGE &other);
// returns the complete IP_RANGE
- std::string to_string(void) const;
+ std::string to_string(bool always_mask=false) const;
// returns the complete range in cidr blocks
std::vector<IP_RANGE> to_cidr(void) const;
vector<IP_RANGE> check_range;
check_range.push_back("192.168.1.61");
- vector<IP_RANGE>::const_iterator it, it_end = new_range.end();
- for (it = new_range.begin(); it != it_end; it++) {
- vector<IP_RANGE> cidrs = it->to_cidr();
- vector<IP_RANGE>::const_iterator cidr, cidrs_end = cidrs.end();
- for (cidr = cidrs.begin(); cidr != cidrs_end; cidr++)
- cerr << "Range as CIDR: " << cidr->to_string() << endl;
- }
-
CPPUNIT_ASSERT_EQUAL(check_range,new_range);
}
};