From e5f78859cb98ec788a995918ebf96cf874e2e8e8 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 11 Jul 2010 18:37:10 +0200 Subject: [PATCH] network: Oops. Forgot some files. --- header-device | 4 +-- header-port | 2 +- header-zone | 69 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/header-device b/header-device index ab2fb18b..783ed077 100644 --- a/header-device +++ b/header-device @@ -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} } diff --git a/header-port b/header-port index ab2fb18b..d06b2e11 100644 --- a/header-port +++ b/header-port @@ -39,7 +39,7 @@ done function run() { case "${action}" in - create|rem|up|down|status) + edit|add|create|rem|up|down|status) _${action} $@ ;; esac diff --git a/header-zone b/header-zone index 34464ff4..4d41feb4 100644 --- a/header-zone +++ b/header-zone @@ -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} $@ ;; -- 2.39.5