]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/functions/functions.device
Add new function device_get_by_mac_address()
[people/ms/network.git] / src / functions / functions.device
index 0cd6e4ea0cf3cc74f78077c1e118d3fc9206c7ad..ace402209134fbd486c440644a4055957a7a3ee7 100644 (file)
@@ -1111,3 +1111,21 @@ device_get_by_assigned_ip_address() {
        print "${device}"
        return ${EXIT_OK}
 }
+
+device_get_by_mac_address() {
+       local mac=${1}
+
+       assert isset mac
+
+       local device
+
+       for device in $(device_list); do
+               if [ "${mac}" = "$(device_get_address ${device})" ]; then
+                       print "${device}"
+                       return ${EXIT_OK}
+               fi
+       done
+
+       # We could not found a port to the given mac address so we return exit error
+       return ${EXIT_ERROR}
+}