summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-10-04 20:43:18 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-10-04 20:43:18 +0000
commit80eb336c4519308cd7707a7c151473b2305fade5 (patch)
tree03fd5f14fa385135af3b8f05d0694507258a8a12 /etc/inc
parentd0b3b0b1b50f9f9efc55a7790990ea63483cc80e (diff)
downloadpfsense-80eb336c4519308cd7707a7c151473b2305fade5.zip
pfsense-80eb336c4519308cd7707a7c151473b2305fade5.tar.gz
Correctly deterimine if an ip falls within a carp subnet, etc.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/pfsense-utils.inc32
1 files changed, 23 insertions, 9 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index e203636..527a6ee 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -481,9 +481,8 @@ function link_ip_to_carp_interface($ip) {
if($ip == "") return;
$ifdescrs = array('wan', 'lan');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
$ifdescrs['opt' . $j] = "opt" . $j;
- }
$ft = split("\.", $ip);
$ft_ip = $ft[0] . "." . $ft[1] . "." . $ft[2] . ".";
@@ -494,18 +493,33 @@ function link_ip_to_carp_interface($ip) {
for($x=0; $x<$num_carp_ints; $x++) {
$carp_int = "carp{$x}";
$carp_ip = find_interface_ip($carp_int);
- $carp_ft = split("\.", $carp_ip);
- $carp_ft_ip = $carp_ft[0] . "." . $carp_ft[1] . "." . $carp_ft[2] . ".";
- $result = does_interface_exist($carp_int);
- if($result <> true) break;
- if($ft_ip == $carp_ft_ip)
- if(stristr($carp_ints,$carp_int) == false)
- $carp_ints .= " " . $carp_int;
+ $carp_subnet = find_virtual_ip_netmask($carp_ip);
+ if(ip_in_subnet($ip, "{$carp_ip}/{$carp_subnet}"))
+ if(!stristr($carp_ints, $carp_int))
+ $carp_ints .= " " . $carp_int;
}
}
return $carp_ints;
}
+/****f* pfsense-utils/find_virtual_ip_netmask
+ * NAME
+ * find_virtual_ip_netmask - Finds a virtual ip's subnet mask'
+ * INPUTS
+ * $ip - ip address to locate subnet mask of
+ * RESULT
+ * String containing the command's result.
+ * NOTES
+ * This function returns the command's stdout and stderr.
+ ******/
+function find_virtual_ip_netmask($ip) {
+ global $config;
+ foreach($config['virtualip']['vip'] as $vip) {
+ if($ip == $vip['subnet'])
+ return $vip['subnet_bits'];
+ }
+}
+
/****f* pfsense-utils/exec_command
* NAME
* exec_command - Execute a command and return a string of the result.
OpenPOWER on IntegriCloud