Project

General

Profile

« Previous | Next » 

Revision 76a56fce

Added by Stilez y about 9 years ago

Remove subnet_expand()

Function isn't used in main or packages repo, and in any case would need a complete rewrite to handle IPv6.
(cherry picked from commit 6215902c4043726e633fcfac1c37c710ac398653)

View differences:

src/etc/inc/util.inc
877 877
	}
878 878
}
879 879

  
880

  
881
function subnet_expand($subnet) {
882
	if (is_subnetv4($subnet)) {
883
		return subnetv4_expand($subnet);
884
	} else if (is_subnetv6($subnet)) {
885
		return subnetv6_expand($subnet);
886
	} else {
887
		return $subnet;
888
	}
889
}
890

  
891
function subnetv4_expand($subnet) {
892
	$result = array();
893
	list ($ip, $bits) = explode("/", $subnet);
894
	$net = ip2long($ip);
895
	$mask = (0xffffffff << (32 - $bits));
896
	$net &= $mask;
897
	$size = round(exp(log(2) * (32 - $bits)));
898
	for ($i = 0; $i < $size; $i += 1) {
899
		$result[] = long2ip($net | $i);
900
	}
901
	return $result;
902
}
903

  
904 880
/* find out whether two IPv4/IPv6 CIDR subnets overlap.
905 881
   Note: CIDR overlap implies one is identical or included so largest sn will be the same */
906 882
function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2) {

Also available in: Unified diff