]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/hooks/ports/dummy
hotplug: Remove multiple copies of the same function
[people/ms/network.git] / src / hooks / ports / dummy
index 61d2f94ee9d6c1e01e7d03204237136ac8697418..36888319439cb8cb504c866f099c8b8fad21f084 100644 (file)
@@ -21,7 +21,9 @@
 
 . /usr/lib/network/header-port
 
-HOOK_SETTINGS="ADDRESS"
+HOOK_SETTINGS=(
+       "ADDRESS"
+)
 
 hook_check_settings() {
        assert ismac ADDRESS
@@ -60,7 +62,7 @@ hook_new() {
        local port=$(port_find_free ${DUMMY_PORT_PATTERN})
        assert isset port
 
-       if port_settings_write "${port}" ${HOOK_SETTINGS}; then
+       if port_settings_write "${port}"; then
                log INFO "New dummy port '${port}' has been created"
        fi
 
@@ -72,7 +74,7 @@ hook_create() {
        assert isset port
 
        # Read configuration
-       port_settings_read "${port}" ${HOOK_SETTINGS}
+       port_settings_read "${port}"
 
        # Create the dummy device
        dummy_create "${port}" "${ADDRESS}"
@@ -88,40 +90,6 @@ hook_remove() {
        dummy_remove "${port}"
 }
 
-hook_up() {
-       local port="${1}"
-       assert isset port
-
-       # Bring up the port.
-       device_set_up ${port}
-
-       exit ${EXIT_OK}
-}
-
-hook_down() {
-       local port="${1}"
-       assert isset port
-
-       # Tear down the port.
-       device_set_down ${port}
-
-       exit ${EXIT_OK}
-}
-
 hook_hotplug_rename() {
-       local port=${1}
-       assert isset port
-
-       local device=${2}
-       assert isset device
-
-       port_settings_read "${port}" ${HOOK_SETTINGS}
-
-       if [ "${ADDRESS}" = "$(device_get_address ${device})" ]; then
-               log DEBUG "Device '${device}' equals port '${port}'."
-               exit ${EXIT_OK}
-       fi
-
-       log DEBUG "Device '${device}' does not equal port '${port}'."
-       exit ${EXIT_ERROR}
+       hook_hotplug_rename_by_address "$@"
 }