|
@@ 198-205 (lines=8) @@
|
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
/* return the subnet address given a host address and a subnet bit count */ |
| 198 |
|
public static function gen_subnet($ipaddr, $bits) |
| 199 |
|
{ |
| 200 |
|
if (!self::is_ipaddr($ipaddr) || !is_numeric($bits)) { |
| 201 |
|
return ""; |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
return long2ip(ip2long($ipaddr) & self::gen_subnet_mask_long($bits)); |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
/* returns a subnet mask (long given a bit count) */ |
| 208 |
|
public static function gen_subnet_mask_long($bits) |
|
@@ 220-227 (lines=8) @@
|
| 217 |
|
|
| 218 |
|
/* return the highest (broadcast) address in the subnet given a host address and |
| 219 |
|
a subnet bit count */ |
| 220 |
|
public static function gen_subnet_max($ipaddr, $bits) |
| 221 |
|
{ |
| 222 |
|
if (!self::is_ipaddr($ipaddr) || !is_numeric($bits)) { |
| 223 |
|
return ""; |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
return self::long2ip32(ip2long($ipaddr) | ~self::gen_subnet_mask_long($bits)); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
/* takes an array of ip address, sorts and returns as an array */ |
| 230 |
|
public static function sort_addresses($ipaddr) |