]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/header-zone
Merge remote-tracking branch 'prime/master'
[people/stevee/network.git] / src / header-zone
index 2120377d5aa23f9049d8426846de830ba3c26e3d..c445d55fbf7666e6fc706a3cfb5a63ef0bd1de2e 100644 (file)
 #                                                                             #
 ###############################################################################
 
-function hook_info() {
+hook_info() {
        echo "HOOK=\"${HOOK}\""
 }
 
-function hook_create() {
+hook_hotplug() {
+       # If the hook does not handle the hotplug event, it
+       # must return EXIT_NOT_HANDLED.
+       exit ${EXIT_NOT_HANDLED}
+}
+
+hook_new() {
        local zone="${1}"
        assert isset zone
        shift
 
-       settings_read $(zone_dir ${zone})/settings
+       zone_settings_read "${zone}"
 
        hook_parse_cmdline $@
 
-       settings_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
+       zone_settings_write "${zone}"
 
        exit ${EXIT_OK}
 }
 
-function hook_edit() {
-       hook_create $@
+hook_edit() {
+       hook_new $@
 }
 
-function hook_remove() {
+hook_remove() {
        cmd_not_implemented
 }
 
-function hook_status() {
+hook_status() {
        local zone="${1}"
        assert isset zone
 
@@ -56,36 +62,25 @@ function hook_status() {
        exit ${STATUS_DOWN}
 }
 
-function hook_up() {
+hook_up() {
        cmd_not_implemented
 }
 
-function hook_down() {
+hook_down() {
        cmd_not_implemented
 }
 
-function hook_discover() {
+hook_discover() {
        # This hook does not support a discovery
        exit ${DISCOVER_NOT_SUPPORTED}
 }
 
-# The default help function.
-function hook_help() {
-       # If no man page has been configured, we print an error message.
-       if [ -z "${HOOK_MANPAGE}" ]; then
-               error "There is no help available for hook '${HOOK}'. Exiting."
-               exit ${EXIT_ERROR}
-       fi
-
-       cli_show_man ${HOOK_MANPAGE}
-}
-
 # Do nothing
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
        return ${EXIT_OK}
 }
 
-function hook_port() {
+hook_port() {
        local zone="${1}"
        assert isset zone
 
@@ -107,35 +102,57 @@ function hook_port() {
        exit ${ret}
 }
 
-function hook_port_add() {
+hook_port_attach() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_edit() {
+hook_port_detach() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_remove() {
+hook_port_edit() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_show() {
-       cmd_not_implemented
+hook_port_status() {
+       return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_status() {
-       return ${EXIT_NOT_SUPPORTED}
+hook_default_port_create() {
+       assert [ $# -ge 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       port_create "${port}"
+}
+
+hook_port_create() {
+       hook_default_port_create $@
+}
+
+hook_default_port_remove() {
+       assert [ $# -ge 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       port_remove "${port}"
+}
+
+hook_port_remove() {
+       hook_default_port_remove $@
 }
 
-function hook_port_up() {
+hook_port_up() {
        cmd_not_implemented
 }
 
-function hook_port_down() {
+hook_port_down() {
        cmd_not_implemented
 }
 
-function hook_config() {
+hook_config() {
        local zone="${1}"
        assert isset zone
 
@@ -145,7 +162,7 @@ function hook_config() {
 
        local ret
        case "${action}" in
-               create|edit|rem|show)
+               new|destroy|edit|show)
                        hook_config_${action} "${zone}" "$@"
                        exit $?
                        ;;
@@ -156,7 +173,7 @@ function hook_config() {
        esac
 }
 
-function hook_config_cmd() {
+hook_config_cmd() {
        local cmd="${1}"
        assert isset cmd
 
@@ -182,31 +199,31 @@ function hook_config_cmd() {
        hook_config_exec "${hook_config}" "${cmd}" "${zone}" "$@"
 }
 
-function hook_config_create() {
-       assert [ $# -gt 2 ]
+hook_config_new() {
+       assert [ $# -ge 2 ]
 
-       hook_config_cmd "create" "$@"
+       hook_config_cmd "new" "$@"
 }
 
-function hook_config_edit() {
-       hook_config_cmd "edit" "$@"
+hook_config_destroy() {
+       hook_config_cmd "destroy" "$@"
 }
 
-function hook_config_remove() {
-       hook_config_cmd "remove" "$@"
+hook_config_edit() {
+       hook_config_cmd "edit" "$@"
 }
 
-function hook_config_show() {
+hook_config_show() {
        cmd_not_implemented
 }
 
-function hook_ppp_write_config() {
+hook_ppp_write_config() {
        cmd_not_implemented
 
        # Arguments: <zone> <filename>
 }
 
-function hook_ppp_ip_pre_up() {
+hook_ppp_ip_pre_up() {
        local zone="${1}"
        assert isset zone
        shift
@@ -220,7 +237,7 @@ function hook_ppp_ip_pre_up() {
        exit $?
 }
 
-function hook_ppp_ipv4_up() {
+hook_ppp_ipv4_up() {
        local zone="${1}"
        assert isset zone
        shift
@@ -234,7 +251,7 @@ function hook_ppp_ipv4_up() {
        exit $?
 }
 
-function hook_ppp_ipv4_down() {
+hook_ppp_ipv4_down() {
        local zone="${1}"
        assert isset zone
        shift
@@ -248,7 +265,7 @@ function hook_ppp_ipv4_down() {
        exit $?
 }
 
-function hook_ppp_ipv6_up() {
+hook_ppp_ipv6_up() {
        local zone="${1}"
        assert isset zone
        shift
@@ -262,7 +279,7 @@ function hook_ppp_ipv6_up() {
        exit $?
 }
 
-function hook_ppp_ipv6_down() {
+hook_ppp_ipv6_down() {
        local zone="${1}"
        assert isset zone
        shift