|
@@ 186-193 (lines=8) @@
|
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
/* return the subnet address given a host address and a subnet bit count */ |
| 186 |
|
public static function gen_subnet($ipaddr, $bits) |
| 187 |
|
{ |
| 188 |
|
if (!self::is_ipaddr($ipaddr) || !is_numeric($bits)) { |
| 189 |
|
return ""; |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
return long2ip(ip2long($ipaddr) & self::gen_subnet_mask_long($bits)); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
/* returns a subnet mask (long given a bit count) */ |
| 196 |
|
public static function gen_subnet_mask_long($bits) |
|
@@ 208-215 (lines=8) @@
|
| 205 |
|
|
| 206 |
|
/* return the highest (broadcast) address in the subnet given a host address and |
| 207 |
|
a subnet bit count */ |
| 208 |
|
public static function gen_subnet_max($ipaddr, $bits) |
| 209 |
|
{ |
| 210 |
|
if (!self::is_ipaddr($ipaddr) || !is_numeric($bits)) { |
| 211 |
|
return ""; |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
return self::long2ip32(ip2long($ipaddr) | ~self::gen_subnet_mask_long($bits)); |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
/* takes an array of ip address, sorts and returns as an array */ |
| 218 |
|
public static function sort_addresses($ipaddr) |