We need this function and the command to identify ports in a nitsi test.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.device | 18 ++++++++++++++++++ src/network | 3 +++ 2 files changed, 21 insertions(+)
diff --git a/src/functions/functions.device b/src/functions/functions.device index 0cd6e4e..ace4022 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -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} +} diff --git a/src/network b/src/network index b28ecdb..f26c0dc 100644 --- a/src/network +++ b/src/network @@ -1286,6 +1286,9 @@ cli_raw() { db-dump) db_dump ;; + device-get-by-mac-address) + device_get_by_mac_address "$@" + ;; ipsec-connection-exists) ipsec_connection_exists "$@" ;;