From c7ad780177fbe09a390350b249e00d78db3d4759 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 4 Jun 2010 00:11:36 +0200 Subject: [PATCH] network: Create some default actions for the ppp events. --- functions.events | 2 -- functions.ppp | 45 +++++++++++++++++++++++++++++++++++++++++++++ header-zone | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/functions.events b/functions.events index 1dd98a53..720ee20e 100644 --- a/functions.events +++ b/functions.events @@ -13,14 +13,12 @@ function event_firewall_reload() { event_emit firewall-reload } -# XXX dunno what this does. function event_interface_up() { local iface=${1} event_emit network-interface-up IFACE=${iface} } -# XXX dunno what this does. function event_interface_down() { local iface=${1} diff --git a/functions.ppp b/functions.ppp index 82038512..631a3c88 100644 --- a/functions.ppp +++ b/functions.ppp @@ -43,6 +43,51 @@ function ppp_post_down() { #connection --down --zone=${zone} } +function ppp_common_ip_pre_up() { + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + return ${EXIT_ERROR} + fi + + # Request firewall reload + event_firewall_reload + + return ${EXIT_OK} +} + +function ppp_common_ip_up() { + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + return ${EXIT_ERROR} + fi + + # Emit interface-up event + event_interface_up ${zone} + + return ${EXIT_OK} +} + +function ppp_common_ip_down() { + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + return ${EXIT_ERROR} + fi + + # Emit interface-up event + event_interface_down ${zone} + + return ${EXIT_OK} +} + function ppp_secret() { local USER=${1} local SECRET=${2} diff --git a/header-zone b/header-zone index 3ece8486..88ed0216 100644 --- a/header-zone +++ b/header-zone @@ -223,17 +223,46 @@ function _config_show() { _notimplemented _config_show } -# These tree functions exit silently function _ppp-ip-pre-up() { - exit ${EXIT_OK} + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + exit ${EXIT_ERROR} + fi + + ppp_common_ip_pre_up ${zone} $@ + + exit $? } function _ppp-ip-up() { - exit ${EXIT_OK} + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + exit ${EXIT_ERROR} + fi + + ppp_common_ip_up ${zone} $@ + + exit $? } function _ppp-ip-down() { - exit ${EXIT_OK} + local zone=${1} + shift + + if ! zone_exists ${zone}; then + error "Zone '${zone}' does not exist." + exit ${EXIT_ERROR} + fi + + ppp_common_ip_down ${zone} $@ + + exit $? } function run() { -- 2.39.2