From: Michael Tremer Date: Thu, 3 Jun 2010 22:11:36 +0000 (+0200) Subject: network: Create some default actions for the ppp events. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4166b79b1cd955a0cf022714a3b91a03e49bfa4;p=ipfire-3.x.git network: Create some default actions for the ppp events. --- diff --git a/pkgs/core/network/src/functions.events b/pkgs/core/network/src/functions.events index 1dd98a538..720ee20e9 100644 --- a/pkgs/core/network/src/functions.events +++ b/pkgs/core/network/src/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/pkgs/core/network/src/functions.ppp b/pkgs/core/network/src/functions.ppp index 82038512d..631a3c88b 100644 --- a/pkgs/core/network/src/functions.ppp +++ b/pkgs/core/network/src/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/pkgs/core/network/src/header-zone b/pkgs/core/network/src/header-zone index 3ece84863..88ed0216e 100644 --- a/pkgs/core/network/src/header-zone +++ b/pkgs/core/network/src/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() {