From: Michael Tremer Date: Thu, 10 Aug 2017 21:39:47 +0000 (+0200) Subject: ports: Improve function that returns the children X-Git-Tag: 009~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7da8cf02500182e3ef54bb30e1491a198d7fe7af;p=network.git ports: Improve function that returns the children Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.hook b/src/functions/functions.hook index d2f4a789..e910c68e 100644 --- a/src/functions/functions.hook +++ b/src/functions/functions.hook @@ -232,7 +232,7 @@ hook_valid_command_port() { ;; # Status - status|info) + status|info|children) return ${EXIT_TRUE} ;; esac diff --git a/src/functions/functions.ports b/src/functions/functions.ports index bef76be8..c852a53a 100644 --- a/src/functions/functions.ports +++ b/src/functions/functions.ports @@ -335,7 +335,9 @@ port_get_parents() { port_get_children() { local port=${1} - port_get_info ${port} PORT_CHILDREN + assert port_exists "${port}" + + port_cmd "children" "${port}" } port_zone() { diff --git a/src/header-port b/src/header-port index 8756e240..ca1b0917 100644 --- a/src/header-port +++ b/src/header-port @@ -64,6 +64,18 @@ hook_edit() { hook_default_edit $@ } +# Returns a list of all children of this port +hook_children() { + local port="${1}" + + if ! port_settings_read "${port}" ${HOOK_SETTINGS}; then + log ERROR "Could not read port settings: ${port}" + return ${EXIT_OK} + fi + + print "${SLAVES}" +} + hook_info() { local port="${1}" assert isset port