- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
// Check if the subnet begins with $startip and ends before $endip
if (($targetsub_min == $startip) && ip_less_than($targetsub_max, $endip)) {
break;
}
// Check if the subnet ends at $endip and starts after $startip
if (ip_greater_than($targetsub_min, $startip) && ($targetsub_max == $endip)) {
break;
}
// Check if the subnet is between $startip and $endip
if (ip_greater_than($targetsub_min, $startip) && ip_less_than($targetsub_max, $endip)) {
break;
}
Python 3.4.1 (default, May 23 2014, 17:48:28) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ipaddress import ip_address as IP
>>> IP('127.0.0.0') < IP('127.0.0.1') < IP('127.0.0.255')
True
>>> IP('127.0.0.0') < IP('8.8.8.8') < IP('127.0.0.255')
False
Гы-гы.