summaryrefslogtreecommitdiffstats
path: root/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-05-05 16:51:41 +0000
committerErmal Luçi <eri@pfsense.org>2009-05-05 16:51:41 +0000
commite88fbe5021ac4d303971b4578375156489a9b259 (patch)
tree4fab682210f9e3d1429f1b33edcb784efcfc350e /etc/inc/pfsense-utils.inc
parent90ba56adcad9958a92daeb0293a0aa567a383e7f (diff)
downloadpfsense-e88fbe5021ac4d303971b4578375156489a9b259.zip
pfsense-e88fbe5021ac4d303971b4578375156489a9b259.tar.gz
* Teach get_interface_subnet() about carp.
* Increase scope to all interfaces when searching for the carp parent since the later is used even on those scopes. * General cleanup of unused vars and code.
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r--etc/inc/pfsense-utils.inc56
1 files changed, 24 insertions, 32 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index db65331..c0006cf 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -534,28 +534,25 @@ function find_number_of_created_carp_interfaces($flush = false) {
function link_carp_interface_to_parent($interface) {
global $config;
- if($interface == "") return;
- /* if list */
- $ifdescrs = get_configured_interface_list();
+ if ($interface == "")
+ return;
- $carp_int = $interface;
$carp_ip = find_interface_ip($interface);
- $carp_subnet = find_virtual_ip_netmask($carp_ip);
- $starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}");
- $carp_ints = "";
+ if (!is_ipaddr($carp_ip))
+ return;
+ /* if list */
+ $ifdescrs = get_configured_interface_list();
foreach ($ifdescrs as $ifdescr => $ifname) {
- if(interface_has_gateway($ifname)) {
- $interfaceip = get_interface_ip($ifname);
- $subnet_bits = get_interface_subnet($ifname);
- $subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}");
- if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}")) {
- return $ifname;
- }
- }
+ $interfaceip = get_interface_ip($ifname);
+ $subnet_bits = get_interface_subnet($ifname);
+ $subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}");
+ if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}"))
+ return $ifname;
}
- return $carp_ints;
+
+ return "";
}
/****f* pfsense-utils/link_ip_to_carp_interface
@@ -568,27 +565,22 @@ function link_carp_interface_to_parent($interface) {
******/
function link_ip_to_carp_interface($ip) {
global $config;
- if($ip == "") return;
- /* if list */
- $ifdescrs = get_configured_interface_list();
-
- $ft = split("\.", $ip);
- $ft_ip = $ft[0] . "." . $ft[1] . "." . $ft[2] . ".";
+ if (!is_ipaddr($ip))
+ return;
$carp_ints = "";
$num_carp_ints = find_number_of_created_carp_interfaces();
- foreach ($ifdescrs as $ifdescr => $ifname) {
- for($x=0; $x<$num_carp_ints; $x++) {
- $carp_int = "carp{$x}";
- $carp_ip = find_interface_ip($carp_int);
- $carp_subnet = find_virtual_ip_netmask($carp_ip);
- $starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}");
- if(ip_in_subnet($ip, "{$starting_ip}/{$carp_subnet}"))
- if(!stristr($carp_ints, $carp_int))
- $carp_ints .= " " . $carp_int;
- }
+ for ($x=0; $x<$num_carp_ints; $x++) {
+ $carp_int = "carp{$x}";
+ $carp_ip = find_interface_ip($carp_int);
+ $carp_subnet = find_virtual_ip_netmask($carp_ip);
+ $starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}");
+ if (ip_in_subnet($ip, "{$starting_ip}/{$carp_subnet}"))
+ if(!stristr($carp_ints, $carp_int))
+ $carp_ints .= " " . $carp_int;
}
+
return $carp_ints;
}
OpenPOWER on IntegriCloud