diff options
author | Chris Buechler <cmb@pfsense.org> | 2010-07-27 21:21:22 -0400 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2010-07-27 21:21:22 -0400 |
commit | cb847796df756202c4667b68c081a9766f0ce736 (patch) | |
tree | 8c5af10844a5f8d3a6bb4b1d256ff97240bd24aa /etc/inc | |
parent | 81c642846be251a5ae45364c5e81405dd033c7a2 (diff) | |
download | pfsense-cb847796df756202c4667b68c081a9766f0ce736.zip pfsense-cb847796df756202c4667b68c081a9766f0ce736.tar.gz |
use more efficient is_macaddr from bblacey on forum
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/util.inc | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index da1b496..ced2be0 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -433,21 +433,7 @@ function is_domain($domain) { /* returns true if $macaddr is a valid MAC address */ function is_macaddr($macaddr) { - if (!is_string($macaddr)) - return false; - - $maca = explode(":", $macaddr); - if (count($maca) != 6) - return false; - - foreach ($maca as $macel) { - if (($macel === "") || (strlen($macel) > 2)) - return false; - if (preg_match("/[^0-9a-f]/i", $macel)) - return false; - } - - return true; + return preg_match('/^[0-9A-F]{2}(?=([:]?))(?:\\1[0-9A-F]{2}){5}$/i', $macaddr) == 1 ? true : false; } /* returns true if $name is a valid name for an alias */ @@ -1384,4 +1370,4 @@ function array_merge_recursive_unique($array0, $array1) return $result; } -?> +?>
\ No newline at end of file |