]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ports: Improve function that returns the children
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Aug 2017 21:39:47 +0000 (23:39 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Aug 2017 21:39:47 +0000 (23:39 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.hook
src/functions/functions.ports
src/header-port

index d2f4a78902bb0016725641058e53563495d91285..e910c68e1487995a84308160cd002c69ccaececf 100644 (file)
@@ -232,7 +232,7 @@ hook_valid_command_port() {
                        ;;
 
                # Status
-               status|info)
+               status|info|children)
                        return ${EXIT_TRUE}
                        ;;
        esac
index bef76be82f2046b1d3252b1210999196c0ef7d78..c852a53ae8a6e7fa064225201278ce894fe8d484 100644 (file)
@@ -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() {
index 8756e24065ccf7e5014a57236dfbb06a192407ca..ca1b0917356de8460cb5ce953baa5fb17c445f5c 100644 (file)
@@ -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