summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Beaver <sbeaver@netgate.com>2016-12-20 12:01:10 -0500
committerSteve Beaver <sbeaver@netgate.com>2016-12-20 12:01:10 -0500
commit0ded76a663457ff3d2b9457ed7447ac3a200f999 (patch)
treec02ab5134aaa0c25dd4fc5137c6188b6f7909099
parentdc5edc6e9840a53e6c7153414c1d0e1066efd058 (diff)
parent74999ad8c4cd2ae5e96c4ae21ee09a246b0a029b (diff)
downloadpfsense-0ded76a663457ff3d2b9457ed7447ac3a200f999.zip
pfsense-0ded76a663457ff3d2b9457ed7447ac3a200f999.tar.gz
Merge pull request #3298 from phil-davis/patch-7
-rw-r--r--src/etc/inc/util.inc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index 66b4a43..528fe0e 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -2481,14 +2481,20 @@ function get_smart_drive_list() {
// $label: the label used by the GUI to display this value. Required to compose an error message
// $err_msg: pointer to the callers error message array so that error messages can be added to it here
// $alias: are aliases permitted for this address?
+// Returns:
+// IPV4 - if $addr is a valid IPv4 address
+// IPV6 - if $addr is a valid IPv6 address
+// ALIAS - if $alias=true and $addr is an alias
+// false - otherwise
+
function validateipaddr(&$addr, $type, $label, &$err_msg, $alias=false) {
switch ($type) {
case IPV4:
if (is_ipaddrv4($addr)) {
- return true;
+ return IPV4;
} else if ($alias) {
if (is_alias($addr)) {
- return true;
+ return ALIAS;
} else {
$err_msg[] = sprintf(gettext("%s must be a valid IPv4 address or alias."), $label);
return false;
@@ -2501,10 +2507,10 @@ function validateipaddr(&$addr, $type, $label, &$err_msg, $alias=false) {
case IPV6:
if (is_ipaddrv6($addr)) {
$addr = strtolower($addr);
- return true;
+ return IPV6;
} else if ($alias) {
if (is_alias($addr)) {
- return true;
+ return ALIAS;
} else {
$err_msg[] = sprintf(gettext("%s must be a valid IPv6 address or alias."), $label);
return false;
@@ -2517,12 +2523,12 @@ function validateipaddr(&$addr, $type, $label, &$err_msg, $alias=false) {
case IPV4V6:
if (is_ipaddrv6($addr)) {
$addr = strtolower($addr);
- return true;
+ return IPV6;
} else if (is_ipaddrv4($addr)) {
- return true;
+ return IPV4;
} else if ($alias) {
if (is_alias($addr)) {
- return true;
+ return ALIAS;
} else {
$err_msg[] = sprintf(gettext("%s must be a valid IPv4 or IPv6 address or alias."), $label);
return false;
OpenPOWER on IntegriCloud