]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
network-functions.pl: Add MAC address compare function
authorLeo-Andres Hofmann <hofmann@leo-andres.de>
Wed, 24 Mar 2021 16:47:15 +0000 (17:47 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 Mar 2021 09:21:39 +0000 (09:21 +0000)
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/network-functions.pl

index e94404f05418925fd36c859715bdace42fc26067..9908ee8abd2089962f8a482f8222edc1066c7106 100644 (file)
@@ -431,6 +431,18 @@ sub valid_mac($) {
        return $mac =~ /^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$/;
 }
 
+# Compares two MAC addresses and returns true if they are equal
+sub is_mac_equal {
+       my $mac_1 = uc shift; # convert to upper case
+       my $mac_2 = uc shift;
+
+       if(valid_mac($mac_1) && valid_mac($mac_2) && ($mac_1 eq $mac_2)) {
+               return 1;
+       }
+
+       return 0;
+}
+
 sub random_mac {
        my $address = "02";