]> git.ipfire.org Git - people/arne_f/network.git/commitdiff
network: Oops. Forgot some files.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jul 2010 16:37:10 +0000 (18:37 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jul 2010 16:37:10 +0000 (18:37 +0200)
header-device
header-port
header-zone

index ab2fb18b874523f2348faa50f417d65ff41237c4..783ed077ed57ad420a2456dda542a2eb33de8556 100644 (file)
@@ -39,11 +39,11 @@ done
 
 function run() {
        case "${action}" in
-               create|rem|up|down|status)
+               add|create|rem|up|down|status)
                        _${action} $@
                        ;;
        esac
 
-       error "Port hook '${HOOK}' didn't exit properly."
+       error "Device hook '${HOOK}' didn't exit properly."
        exit ${EXIT_ERROR}
 }
index ab2fb18b874523f2348faa50f417d65ff41237c4..d06b2e119903ec8e8982492d0982373cc46283f2 100644 (file)
@@ -39,7 +39,7 @@ done
 
 function run() {
        case "${action}" in
-               create|rem|up|down|status)
+               edit|add|create|rem|up|down|status)
                        _${action} $@
                        ;;
        esac
index 34464ff461b4f703996c7054f1fd1fd493235d4d..4d41feb45e7aa5c0a29cacc5334dd9fcaf0f16d4 100644 (file)
@@ -60,11 +60,11 @@ function _create() {
        local zone=${1}
        shift
 
-       config_read ${ZONE_DIR}/${zone}/settings
+       config_read $(zone_dir ${zone})/settings
 
        _parse_cmdline $@
 
-       config_write ${ZONE_DIR}/${zone}/settings ${HOOK_SETTINGS}
+       config_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
 
        exit ${EXIT_OK}
 }
@@ -113,7 +113,7 @@ function _port() {
        local ret
 
        case "${action}" in
-               create|edit|rem|show)
+               add|create|edit|rem|show)
                        _port_${action} ${zone} $@
                        ret=$?
                        ;;
@@ -126,42 +126,58 @@ function _port() {
        exit ${ret}
 }
 
-# This function is not a public one
-function __portcmd() {
+function _port_add() {
+       _port_cmd add $@
+}
+
+function _port_edit() {
+       _port_cmd edit $@
+}
+
+function _port_rem() {
+       _port_cmd rem $@
+}
+
+function _port_show() {
+       _notimplemented _port_show
+}
+
+function _port_status() {
+       _port_cmd status $@
+}
+
+function _port_cmd() {
        local cmd=${1}
        local zone=${2}
-       local hook_port=${3}
+       local port=${3}
        shift 3
 
+       assert isset cmd
+       assert isset zone
+       assert isset port
+
        local hook_zone=$(zone_get_hook ${zone})
+       local hook_port=$(port_get_hook ${port})
 
-       if ! hook_zone_exists ${hook_zone}; then
-               error "Hook '${hook}' does not exist."
-               exit ${EXIT_ERROR}
-       fi
+       assert isset hook_zone
+       assert isset hook_port
 
-       if ! hook_zone_port_exists ${hook_zone} ${hook_port}; then
-               error "Hook '${hook_port}' is not supported for zone '${zone}'."
+       if ! listmatch ${hook_port} $(zone_get_supported_hooks ${zone}); then
+               error_log "Zone '${zone}' does not support port of type '${hook_port}'."
                exit ${EXIT_ERROR}
        fi
 
-       hook_zone_port_exec ${hook_zone} ${hook_port} ${cmd} ${zone} $@
-}
+       hook_zone_port_exec ${hook_zone} ${hook_port} ${cmd} ${zone} ${port} $@
 
-function _port_create() {
-       __portcmd create $@
-}
-
-function _port_edit() {
-       __portcmd edit $@
+       exit $?
 }
 
-function _port_rem() {
-       _notimplemented _port_rem
+function _port_up() {
+       _port_cmd up $@
 }
 
-function _port_show() {
-       _notimplemented _port_show
+function _port_down() {
+       _port_cmd down $@
 }
 
 function _config() {
@@ -266,8 +282,11 @@ function _ppp-ip-down() {
 }
 
 function run() {
+       # Replace all dashes by an underscore
+       #action=${action//-/_}
+
        case "${action}" in
-               create|discover|down|edit|info|rem|status|up)
+               create|discover|down|edit|info|rem|status|up|port_add|port_rem|port_up|port_down|port_status)
                        _${action} $@
                        ;;