summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorsmos <seth.mos@dds.nl>2011-08-23 20:39:37 +0200
committersmos <seth.mos@dds.nl>2011-08-23 20:46:51 +0200
commit318189b6b43b30d95ff0b313167f65713607d87b (patch)
tree129bef3b473b929d7759ee1d81e51871b8107784 /etc
parentb4eec6e60a0949c4d2408ba314bc37a0ddceed91 (diff)
downloadpfsense-318189b6b43b30d95ff0b313167f65713607d87b.zip
pfsense-318189b6b43b30d95ff0b313167f65713607d87b.tar.gz
Add a function that allows you to validate the address family on 2 addresses or 1 address and a gateway name. the gateway name must be the 2nd argument.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/gwlb.inc37
1 files changed, 37 insertions, 0 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index e6232f1..7cbb29d 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -617,4 +617,41 @@ function get_interface_gateway_v6($interface, &$dynamic = false) {
return ($gw);
}
+/* Check a IP address against a gateway IP or name
+ * to verify it's address family */
+function validate_address_family($ipaddr, $gwname) {
+ $v4ip = false;
+ $v6ip = false;
+ $v4gw = false;
+ $v6gw = false;
+
+ if(is_ipaddrv4($ipaddr))
+ $v4ip = true;
+ if(is_ipaddrv6($ipaddr))
+ $v6ip = true;
+ if(is_ipaddrv4($gwname))
+ $v4gw = true;
+ if(is_ipaddrv6($gwname))
+ $v6gw = true;
+
+ if($v4ip && $v4gw)
+ return true;
+ if($v6ip && $v6gw)
+ return true;
+
+ /* still no match, carry on, lookup gateways */
+ if(is_ipaddrv4(lookup_gateway_ip_by_name($gwname)))
+ $v4gw = true;
+ if(is_ipaddrv6(lookup_gateway_ip_by_name($gwname)))
+ $v6gw = true;
+
+ if($v4ip && $v4gw)
+ return true;
+ if($v6ip && $v6gw)
+ return true;
+
+ return false;
+}
+
+
?>
OpenPOWER on IntegriCloud