summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/util.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2017-01-05 18:18:27 -0500
committerjim-p <jimp@pfsense.org>2017-01-05 18:18:27 -0500
commit80e7011fddd29a387c4c84b68c8c49dce4494729 (patch)
tree17e4b250ee0ac7ded3afe2ad90a5af90d190244b /src/etc/inc/util.inc
parentea02e3cf5d54c9f1ebbe09d9fa5522c5c9916876 (diff)
downloadpfsense-80e7011fddd29a387c4c84b68c8c49dce4494729.zip
pfsense-80e7011fddd29a387c4c84b68c8c49dce4494729.tar.gz
Return partial MAC address matching support to is_macaddr(). Fixes #7088
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r--src/etc/inc/util.inc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index df5cdd0..4d157d7 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -986,12 +986,18 @@ function is_domain($domain, $allow_wildcard=false) {
}
/* returns true if $macaddr is a valid MAC address */
-function is_macaddr($macaddr) {
+function is_macaddr($macaddr, $partial=false) {
$values = explode(":", $macaddr);
- if (count($values) != 6) {
+
+ /* Verify if the MAC address has a proper amount of parts for either a partial or full match. */
+ if ($partial) {
+ if ((count($values) < 1) || (count($values) > 6)) {
+ return false;
+ }
+ } elseif (count($values) != 6) {
return false;
}
- for ($i = 0; $i < 6; $i++) {
+ for ($i = 0; $i < count($values); $i++) {
if (ctype_xdigit($values[$i]) == false)
return false;
if (hexdec($values[$i]) < 0 || hexdec($values[$i]) > 255)
OpenPOWER on IntegriCloud